Compare commits

...

94 Commits

Author SHA1 Message Date
Mohd Afeef Badri
de0f832370 Create LICENSE
Previously wrong License type was applied
2024-01-22 10:18:46 +00:00
Mohd Afeef Badri
208072178b Delete COPYING 2024-01-22 10:18:46 +00:00
mbs
6f1ecd26cb Updated copyright comment 2024-01-20 13:59:13 +00:00
cconopoima
c56027a4a2 [bos #38045][EDF] (2023-T3) suppress compilation warnings of new and refactored classes.
Allow compilation in windows.
2024-01-18 10:30:12 +00:00
yoann.audouin
add7adb355 NETGEN_2D_Remote.Paramters was returning a 3D Hypotesis 2024-01-18 10:30:12 +00:00
cconopoima
ccecac5e15 [bos #38045] [EDF] (2023-T3) Stand alone version for Netgen meshers.
Separating mesh face and proxy mesh for quand adaptors and VL in 3D.

Intermedial commit

First version of 1D SA.

2D SA version and definition of simpleHypo.

Define the NETGENPlugin_NETGEN_1D2D3D_SA class to implement 1D,1D2D,1D2D3D SA version of the mesh. Using NETGENPlugin_NETGEN_2D_SA class to define the 2D SA version.

Cleaning code.

Toward 2D SA version.

Function to feed 1D elements from imported mesh into netgen.

2D SA version for netgen.

Finish support for parallel computing of 2D mesh with netgen. Add the NETGEN_2D_Remote. UsIn NETGEN_2D_SA class use bounding box of faces to allow fast discarting edge nodes far from the faces been meshed.
2024-01-18 10:30:12 +00:00
jfa
3af617de21 Increment version: 9.12.0 2023-11-20 18:27:02 +00:00
Guytri KASTANE
0ee85c91e9 #BOS 37851: cast tuple types for compilation on FD38 2023-09-29 15:02:48 +02:00
Yoann Audouin
dae130623f Modifications for multinode parallelism (with windows fixed)
Adding walltime to multinode parameters
bos #37471: fix compilation on Windows operating system
2023-09-26 10:21:46 +02:00
YOANN AUDOUIN
8281d267cb Revert "Modifications for multinode parallelism"
This reverts commit 90d8d4461e.
2023-09-04 07:57:41 +02:00
Yoann Audouin
90d8d4461e Modifications for multinode parallelism 2023-08-31 11:20:34 +02:00
cconopoima
7beb24df6b bos #32671 [EDF] avoid duplicated nodes on internal edge with quadratic elements. 2023-07-21 11:36:43 -03:00
jfa
8c9a6bc255 Merge branch 'V9_11_BR' 2023-07-19 16:12:36 +01:00
Nabil Ghodbane
494b66695d bos #36429: fix compilation issue on windows 2023-07-04 11:11:31 +02:00
mbs
ab749f8f58 updated copyright message 2023-06-19 17:55:24 +01:00
mbs
2d646f5c7d updated copyright message 2023-06-16 20:00:59 +01:00
Yoann Audouin
3230448de9 Correction for random error with NETGEN when multiple computation run at the same time
Netgen is creating a few files while running in the current folder.
Added code to have netgen change current directory when running.
2023-05-31 11:35:57 +02:00
jfa
74d4bf5fb1 Increment version: 9.11.0 2023-05-25 14:55:07 +01:00
BERNHARD Martin OpenCascade
77dd934774 Merge commit '2090e7d4fa6394a4eee1bbf9432dbd09d6e69648' 2023-05-11 15:26:43 +02:00
mbs
2090e7d4fa fixed a compilation problem 2023-04-13 18:05:16 +01:00
asozinov
426282e4b0 Porting to OCCT 7.7.0 2023-04-13 14:40:38 +01:00
Yoann Audouin
04632be459 Corrections for windows 2023-03-28 09:02:14 +02:00
Yoann Audouin
8f71164d60 Update of SMESH api 2023-03-23 11:34:30 +01:00
jfa
5f3ae9218d Merge branch 'V9_10_BR' 2022-12-16 11:14:42 +03:00
jfa
386a6ed69f Increment version: 9.10.0 2022-11-22 14:19:01 +03:00
Yoann Audouin
5bf2f4cc8d Adding new algo for parallel meshing 2022-11-16 09:14:35 +01:00
Yoann Audouin
638fecd6a5 Revert "Merge branch 'yan/parallel_mesh2'"
This reverts commit 92cbce71d3, reversing
changes made to 8142dcc96a.
2022-11-02 10:56:58 +01:00
Yoann Audouin
58f15d2720 Revert "Corrections for parallel smesh"
This reverts commit 1aecb09c15.
2022-11-02 10:56:44 +01:00
Yoann Audouin
1aecb09c15 Corrections for parallel smesh
Was crashing one of the testbase NRT_GRIDS_SMESH_BUGS_08_I1.
Issue was that input info must be sorted to ensure the same number of
volumes in one process.
Also ensure that netgen::mparam parameters are all initialised.
2022-10-24 16:26:57 +02:00
Yoann Audouin
92cbce71d3 Merge branch 'yan/parallel_mesh2' 2022-10-21 15:03:58 +02:00
Yoann Audouin
9bfa36efab Removing 30s limit on QProcess 2022-10-12 10:28:39 +02:00
Konstantin LEONTEV
8142dcc96a [bos #32189][CEA] SALOME README file: updated links to salome site. 2022-10-04 18:24:51 +03:00
Yoann Audouin
75f2fd83a4 Adding comments + removing SMESH_Gen argument 2022-10-04 14:32:49 +02:00
Yoann Audouin
fbfd90a1f8 Adding number of thread to netgen hypo + windows corrections 2022-10-03 18:11:35 +02:00
Yoann Audouin
3d82214289 Adding control of netgen log file 2022-10-03 16:15:33 +02:00
Yoann Audouin
61e4da3b0d Adding nnthreads as parameter for netgen 2022-10-03 15:46:12 +02:00
Yoann Audouin
54a50107a5 Cleanup use of netgen_params + restoring use of netgen error functions 2022-10-03 10:14:02 +02:00
Yoann Audouin
15a5ceeea7 Update of copyright 2022-10-03 08:04:00 +02:00
Yoann Audouin
1a79294029 Using MeshLocker + implementing call to assign for remote plugin 2022-10-03 08:02:37 +02:00
Yoann Audouin
9f2b637978 Cleanup of NETGEN_2D_Only 2022-09-28 08:18:14 +02:00
Yoann Audouin
08f1ef4cc3 cout replaced by MESSAGE + clean up 2022-09-28 08:17:53 +02:00
Yoann Audouin
a99d4c8ed2 Removing hard coded meshname from Mesh import 2022-09-28 08:17:53 +02:00
Yoann Audouin
f6eaf8534d Creating Remote and SA NETGEN_3D plugins 2022-09-28 08:17:53 +02:00
Yoann Audouin
d9a37018c5 Refactoring of runner 2022-09-28 08:17:53 +02:00
Yoann Audouin
1b4859d135 Refactor in runner 2022-09-28 08:17:53 +02:00
Yoann Audouin
3c4eb540f8 Refactoring of normal Compute 2022-09-28 08:17:53 +02:00
Yoann Audouin
0de7ea3ca0 Now filling param _hypParameters and _stdMaxvolume 2022-09-28 08:17:53 +02:00
Yoann Audouin
eb6fde7687 Adding support for BRep for shape 2022-09-28 08:17:53 +02:00
Yoann Audouin
57061f40af Switchin to QProcess instead of sytem for remote compute 2022-09-28 08:17:53 +02:00
Yoann Audouin
2e8bc3b2b0 Better handle of deletion of temporary folder + missing delete of temporary SMESH_Mesh 2022-09-28 08:17:53 +02:00
Yoann Audouin
c59a01e4ce Renaming functions and files + minor corrections in runner_main to detect what to do 2022-09-28 08:17:51 +02:00
Yoann Audouin
2e0b7c8b58 Using RAII to remove file.close 2022-09-28 08:17:27 +02:00
Yoann Audouin
a71af09b16 Adding support of number of thread for the mesher 2022-09-28 08:17:27 +02:00
Yoann Audouin
9c3bd8e9d1 Renaming netgen2d/3d internal calls 2022-09-28 08:17:27 +02:00
Yoann Audouin
0722b0a29e partial work for netgen2d in run_mesher + corrections for netgen3d nodeVec + restoring sequential netgen2D_only 2022-09-28 08:17:27 +02:00
Yoann Audouin
19b9bae48f Generic path for executable 2022-09-28 08:17:27 +02:00
Yoann Audouin
b7289f8536 Integration of run_mesher code 2022-09-28 08:17:27 +02:00
Yoann Audouin
5fae44dd86 restoring original compute + Cleanup 2022-09-28 08:17:27 +02:00
Yoann Audouin
e0e2b32c55 Working version for run_mesher for netgen 3d 2022-09-28 08:17:27 +02:00
Yoann Audouin
acbb35b4c3 Using provider for occgeom and nglib 2022-09-28 08:17:27 +02:00
eap
6fd7220e46 Remove MEFISTO
Set NETGEN_2D as default algorithm
2022-06-08 11:50:53 +03:00
vsr
8842f99357 Merge branch 'V9_9_BR' 2022-05-31 12:11:32 +03:00
vsr
2644070e7c Copyright update 2022 2022-05-05 17:25:00 +03:00
vsr
e583294854 Increment version: 9.9.0 2022-05-05 17:21:35 +03:00
vsr
e084906f8a Merge branch 'V9_8_BR' 2021-12-10 12:39:22 +03:00
eap
11f59dea0b bos #26656 [CEA] NETGEN/NETGENPLUGIN abnormal calculation duration
Enable switching off the parallel meshing
2021-12-01 15:04:30 +03:00
eap
ff44995f59 bos #26656 [CEA] NETGEN/NETGENPLUGIN abnormal calculation duration
Enable switching off the parallel meshing
2021-12-01 14:18:12 +03:00
eap
004d9b9ee8 bos #18711: NETGEN 6 Integration in SALOME
mparams.nthreads = std:🧵:hardware_concurrency();
2021-11-29 14:34:24 +03:00
eap
3bdb54961f bos #18711: NETGEN 6 Integration in SALOME
mparams.nthreads = std:🧵:hardware_concurrency();
2021-11-29 14:20:44 +03:00
eap
73edf7bfa7 compilation error 2021-11-28 20:25:49 +03:00
eap
b2aeed317a compilation error 2021-11-27 15:39:50 +03:00
eap
aa23bb295c bos #26523 EDF 24234 - Viscous Layer
fix wrong treatment of a shrunk FACE with two adjacent FACEs with layers
2021-11-27 14:50:24 +03:00
eap
2238faf39e bos #26523 EDF 24234 - Viscous Layer
fix wrong treatment of a shrunk FACE with two adjacent FACEs with layers
2021-11-27 14:06:46 +03:00
vsr
201d6b5a71 Increment version: 9.8.0 2021-11-27 12:55:33 +03:00
vsr
f994811cbe Merge branch 'occ/26452_face_ori' 2021-11-19 19:04:08 +03:00
eap
be713631b9 bos #26452 [EDF] (2021) SMESH: orientation of faces
follow MESH_MeshEditor change
2021-11-17 18:47:59 +03:00
eap
8ca0ca1fb6 bos #26515 [CEA 24622] Failing SMESH tests
Expose NETGEN version via NETGENPlugin.NETGEN_VERSION_MAJOR constant
  accessible as smeshBuilder.NETGEN_VERSION_MAJOR
2021-10-26 18:27:40 +03:00
rnv
d16cff04dd Build NETGENPLUGIN under Windows platform with Netgen-6 2021-10-11 14:56:50 +03:00
eap
a8606239fd bos #18711 [CEA 18704] COTECH action 117.4: NETGEN 6 Integration in SALOME
cleanup + PATCH
2021-09-06 15:52:51 +03:00
Anthony Geay
74525024bf Netgen available in SSL mode 2021-08-27 11:43:54 +02:00
vsr
fd573fff29 Merge branch 'V9_7_BR' 2021-05-24 17:36:21 +03:00
Anthony Geay
ec7309a62b export into medcoupling data structure 2021-05-18 10:52:37 +02:00
vsr
c0a8715e30 Increment version: 9.7.0 2021-04-27 16:20:34 +03:00
eap
01572b6331 bos #20256: [CEA 18523] Porting SMESH to int 64 bits 2021-04-19 17:33:29 +03:00
vsr
7b43fefa40 Avoid installing redundant files 2021-04-05 21:17:57 +03:00
vsr
a3145d1ba3 Copyright update 2021 2021-03-24 20:52:31 +03:00
Anthony Geay
5dfe064257 WIP 2021-02-03 09:23:21 +01:00
eap
5aa8a56502 bos #20597 EDF 22725 - Problem with NETGEN2D 2021-01-18 18:29:15 +03:00
eap
0f6a0216f7 #18711 [CEA 18704] COTECH action 117.4: NETGEN 6 Integration in SALOME 2020-12-10 13:14:25 +03:00
SALOME
ea5e046236 #18963 Minimize compiler warnings 2020-12-08 19:02:50 +03:00
vsr
0b0d503c15 Merge branch 'V9_6_BR' 2020-11-11 20:10:14 +03:00
vsr
ee6a7e99fa Increment version: 9.6.0 2020-10-16 19:06:20 +03:00
vsr
ecb8c8eee1 Merge branch 'V9_5_BR' 2020-07-10 18:36:22 +03:00
vsr
81c04aeda6 Increment version: 9.5.0 2020-05-19 13:29:57 +03:00
96 changed files with 6530 additions and 1554 deletions

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -17,20 +17,14 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
# Project name
# ============
# original
PROJECT(SalomeNETGENPLUGIN C CXX)
# Versioning
# ===========
# Project name, upper case
# upper case
STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 9)
SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
# Common CMake macros
# ===================
SET(CONFIGURATION_ROOT_DIR $ENV{CONFIGURATION_ROOT_DIR} CACHE PATH "Path to the Salome CMake configuration files")
@ -41,6 +35,11 @@ ELSE()
MESSAGE(FATAL_ERROR "We absolutely need the Salome CMake configuration files, please define CONFIGURATION_ROOT_DIR !")
ENDIF()
# Versioning
# ===========
SALOME_SETUP_VERSION(9.12.0)
MESSAGE(STATUS "Building ${PROJECT_NAME_UC} ${${PROJECT_NAME_UC}_VERSION} from \"${${PROJECT_NAME_UC}_GIT_SHA1}\"")
# Find KERNEL
# ===========
SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
@ -156,6 +155,12 @@ ENDIF(EXISTS ${SMESH_ROOT_DIR})
FIND_PACKAGE(SalomeNetgen REQUIRED)
ADD_DEFINITIONS(${NETGEN_DEFINITIONS})
IF (NETGEN_V6)
SET(NETGEN_VERSION_MAJOR 6)
ELSE()
SET(NETGEN_VERSION_MAJOR 5)
ENDIF()
# Detection summary:
SALOME_PACKAGE_REPORT_AND_CHECK()
@ -216,7 +221,6 @@ ENDIF(SALOME_BUILD_DOC)
# Header configuration
# ====================
SALOME_XVERSION(${PROJECT_NAME})
SALOME_CONFIGURE_FILE(NETGENPLUGIN_version.h.in NETGENPLUGIN_version.h INSTALL ${SALOME_INSTALL_HEADERS})
# Configuration export

340
COPYING
View File

@ -1,340 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

504
LICENSE Normal file
View File

@ -0,0 +1,504 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random
Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

12
README
View File

@ -14,7 +14,7 @@ module.
For more information please visit the SALOME platform web site:
<http://www.salome-platform.org/>
<https://www.salome-platform.org/>
=======
License
@ -23,10 +23,6 @@ License
SALOME platform is distributed under the GNU Lesser General Public License.
See COPYING file for more details.
Also, additional information can be found at SALOME platform web site:
<http://www.salome-platform.org/downloads/license/>
============
Installation
============
@ -43,11 +39,7 @@ site:
* Check Release Notes and Software Requirements of the latest SALOME release at
<http://www.salome-platform.org/downloads/current-version/>
* Pre-requisites page at SALOME web site:
<http://www.salome-platform.org/downloads/license/>
<https://www.salome-platform.org/?page_id=15/>
Note: SALOME Netgen plug-in needs SALOME KERNEL, SALOME GUI, SALOME Geometry and
SALOME Mesh as pre-requisites.

View File

@ -5,7 +5,7 @@
#
###############################################################
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
dnl Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
dnl Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
dnl
dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
dnl Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
dnl Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
dnl
dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View File

@ -1,3 +1,4 @@
[SALOME NETGENPLUGIN] : @SALOMENETGENPLUGIN_VERSION@
[DEVELOPMENT] : @SALOMENETGENPLUGIN_VERSION_DEV@
[SHA1] : @SALOMENETGENPLUGIN_GIT_SHA1@
[DESCRIPTION] : Netgen meshing plug-in for SALOME Mesh module

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
# Copyright (C) 2013-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2013-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -45,8 +45,6 @@ ADD_CUSTOM_TARGET(usr_docs ${CMAKE_COMMAND} -E make_directory tmp
INSTALL(CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" --build ${PROJECT_BINARY_DIR} --target usr_docs)")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/NETGENPLUGIN DESTINATION ${SALOME_INSTALL_DOC}/gui)
INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/NETGENPLUGIN)
INSTALL(FILES images/head.png DESTINATION ${SALOME_INSTALL_DOC}/gui/NETGENPLUGIN/netgenpluginpy_doc)
SET(make_clean_files NETGENPLUGIN netgenpluginpy_doc.tag)
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${make_clean_files}")

View File

@ -30,6 +30,7 @@ HTML_OUTPUT = .
HTML_HEADER = @CMAKE_CURRENT_BINARY_DIR@/static/header.html
HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/static/footer.html
HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/static/salome_extra.css
HTML_EXTRA_FILES = @CMAKE_CURRENT_SOURCE_DIR@/images/head.png
TOC_EXPAND = YES
DISABLE_INDEX = NO
GENERATE_TREEVIEW = YES

View File

@ -93,6 +93,7 @@ HTML_OUTPUT = netgenpluginpy_doc
HTML_HEADER = @CMAKE_CURRENT_BINARY_DIR@/static/header_py.html
HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/static/footer.html
HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/static/salome_extra.css
HTML_EXTRA_FILES = @CMAKE_CURRENT_SOURCE_DIR@/images/head.png
TOC_EXPAND = YES
DISABLE_INDEX = NO
GENERATE_TREEVIEW = YES

View File

@ -4,7 +4,7 @@
<ul>
$navpath
<li class="footer">
Copyright &copy; 2007-2020 CEA/DEN, EDF R&amp;D, OPEN CASCADE<br>
Copyright &copy; 2007-2024 CEA, EDF, OPEN CASCADE<br>
Copyright &copy; 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS<br>
</li>
</ul>

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -27,8 +27,11 @@ INCLUDE_DIRECTORIES(
${PROJECT_BINARY_DIR}/idl
)
SALOME_CONFIGURE_FILE(NETGENPlugin_NETGEN_VERSION.idl.in NETGENPlugin_NETGEN_VERSION.idl)
SET(SalomeIDLNETGENPLUGIN_IDLSOURCES
NETGENPlugin_Algorithm.idl
NETGENPlugin_NETGEN_VERSION.idl
)
SET(_idl_include_dirs

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -44,6 +44,13 @@ module NETGENPlugin
{
};
/*!
* NETGENPlugin_NETGEN_3D: interface of "Remote Tetrahedron (Netgen)" algorithm
*/
interface NETGENPlugin_NETGEN_3D_Remote : NETGENPlugin::NETGENPlugin_NETGEN_3D
{
};
/*!
* NETGENPlugin_NETGEN_2D: interface of "Netgen 1D-2D" algorithm
*/
@ -67,6 +74,13 @@ module NETGENPlugin
{
};
/*!
* NETGENPlugin_NETGEN_2D: interface of "Remote Triangle (Netgen)" algorithm
*/
interface NETGENPlugin_NETGEN_2D_Remote : NETGENPlugin::NETGENPlugin_NETGEN_2D_ONLY
{
};
/*!
* NETGENPlugin_Remesher_2D: interface of "NETGEN Remesher" algorithm,
* generating 2D elements basing on an existing 2D mesh
@ -140,6 +154,9 @@ module NETGENPlugin
void SetWorstElemMeasure(in short val );
short GetWorstElemMeasure();
void SetNbThreads(in short val );
short GetNbThreads();
void SetUseDelauney(in boolean toUse);
boolean GetUseDelauney();
@ -248,12 +265,12 @@ module NETGENPlugin
/*!
* Sets <number of segments> value
*/
void SetNumberOfSegments(in short nb) raises (SALOME::SALOME_Exception);
void SetNumberOfSegments(in long nb) raises (SALOME::SALOME_Exception);
/*!
* Returns <number of segments> value.
* Can be zero in case if LocalLength() has been set
*/
short GetNumberOfSegments();
long GetNumberOfSegments();
/*!
* Sets <segment length> value

View File

@ -0,0 +1,26 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
module NETGENPlugin
{
const short NETGEN_VERSION_MAJOR = @NETGEN_VERSION_MAJOR@ ;
};

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -41,3 +41,4 @@ SET(NETGENPLUGIN_RESOURCES_FILES
)
INSTALL(FILES ${NETGENPLUGIN_RESOURCES_FILES} DESTINATION ${SALOME_NETGENPLUGIN_INSTALL_RES_DATA})
INSTALL(FILES SalomeApp.xml RENAME SalomeAppSL.xml DESTINATION ${SALOME_NETGENPLUGIN_INSTALL_RES_DATA})

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -116,7 +116,7 @@ NETGENPluginGUI_HypothesisCreator::~NETGENPluginGUI_HypothesisCreator()
{
}
bool NETGENPluginGUI_HypothesisCreator::checkParams(QString& msg) const
bool NETGENPluginGUI_HypothesisCreator::checkParams(QString& /*msg*/) const
{
NetgenHypothesisData data_old, data_new;
readParamsFromHypo( data_old );
@ -761,7 +761,7 @@ bool NETGENPluginGUI_HypothesisCreator::readParamsFromHypo( NetgenHypothesisData
NETGENPluginGUI_HypothesisCreator* that = (NETGENPluginGUI_HypothesisCreator*)this;
NETGENPlugin::string_array_var myEntries = h->GetLocalSizeEntries();
for ( size_t i = 0; i < myEntries->length(); i++ )
for ( CORBA::ULong i = 0; i < myEntries->length(); i++ )
{
QString entry = myEntries[i].in();
if (myLocalSizeMap.contains(entry) &&
@ -826,17 +826,17 @@ bool NETGENPluginGUI_HypothesisCreator::storeParamsToHypo( const NetgenHypothesi
if ( myNbSurfOptSteps )
{
h->SetVarParameter ( h_data.myNbSurfOptStepsVar.toLatin1().constData(), "SetNbSurfOptSteps");
h->SetNbSurfOptSteps( h_data.myNbSurfOptSteps );
h->SetNbSurfOptSteps((CORBA::Short) h_data.myNbSurfOptSteps );
}
if ( myNbVolOptSteps )
{
h->SetVarParameter ( h_data.myNbVolOptStepsVar.toLatin1().constData(), "SetNbVolOptSteps");
h->SetNbVolOptSteps( h_data.myNbVolOptSteps );
h->SetNbVolOptSteps((CORBA::Short) h_data.myNbVolOptSteps );
}
if ( myFuseEdges )
h->SetFuseEdges( h_data.myFuseEdges );
h->SetVarParameter ( h_data.myWorstElemMeasureVar.toLatin1().constData(), "SetWorstElemMeasure");
h->SetWorstElemMeasure( h_data.myWorstElemMeasure );
h->SetWorstElemMeasure((CORBA::Short) h_data.myWorstElemMeasure );
h->SetUseDelauney( h_data.myUseDelauney );
h->SetCheckOverlapping( h_data.myCheckOverlapping );

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -63,7 +63,7 @@ public:
NETGENPluginGUI_HypothesisCreator( const QString& );
virtual ~NETGENPluginGUI_HypothesisCreator();
virtual bool checkParams(QString& msg) const;
virtual bool checkParams(QString&) const;
virtual QString helpPage() const;
protected:

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -0,0 +1,293 @@
diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp
index 314d405a..7c912bcc 100644
--- a/libsrc/occ/occgenmesh.cpp
+++ b/libsrc/occ/occgenmesh.cpp
@@ -49,7 +49,7 @@ namespace netgen
double ComputeH (double kappa, const MeshingParameters & mparam)
{
kappa *= mparam.curvaturesafety;
- /*
+ /**/
double hret;
if (mparam.maxh * kappa < 1)
@@ -61,7 +61,7 @@ namespace netgen
hret = mparam.maxh;
return hret;
- */
+ /**/
// return min(mparam.maxh, 1/kappa);
return (mparam.maxh*kappa < 1) ? mparam.maxh : 1/kappa;
}
@@ -253,10 +253,12 @@ namespace netgen
{
oldpnt = pnt;
pnt = c->Value(s0+(i/double(DIVIDEEDGESECTIONS))*(s1-s0));
+ // !!! no more than 1 segment per <edge length>/DIVIDEEDGESECTIONS
hvalue[i] = hvalue[i-1] +
- 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
- pnt.Distance(oldpnt);
+ min( 1.0,
+ 1.0/mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))*
+ pnt.Distance(oldpnt));
//(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z()))
// << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl;
@@ -299,7 +301,7 @@ namespace netgen
cout << "CORRECTED" << endl;
ps.SetSize (nsubedges-2);
params.SetSize (nsubedges);
- params[nsubedges] = s1;
+ params[nsubedges-1] = s1;
}
}
@@ -323,6 +325,8 @@ namespace netgen
double eps = 1e-6 * geom.GetBoundingBox().Diam();
+ int first_vp = mesh.GetNP()+1;
+
tsearch.Start();
for (int i = 1; i <= nvertices; i++)
{
@@ -481,22 +485,107 @@ namespace netgen
if (!merge_solids)
{
- pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge)) + PointIndex::BASE-1;
- pnums.Last() = geom.vmap.FindIndex (TopExp::LastVertex (edge)) + PointIndex::BASE-1;
+ //pnums[0] = geom.vmap.FindIndex (TopExp::FirstVertex (edge)) + PointIndex::BASE-1;
+ //pnums.Last() = geom.vmap.FindIndex (TopExp::LastVertex (edge)) + PointIndex::BASE-1;
+ const int dpi = PointIndex::BASE-1;
+ MeshPoint dfltP ( Point<3> ( 0, 0, 0 ) );
+ PointIndex *ipp[] = { &pnums[0], &pnums.Last() };
+ TopoDS_Iterator vIt( edge, false );
+ TopoDS_Vertex v[2];
+ v[0] = TopoDS::Vertex( vIt.Value() ); vIt.Next();
+ v[1] = TopoDS::Vertex( vIt.Value() );
+ if ( v[0].Orientation() == TopAbs_REVERSED )
+ std::swap( v[0], v[1] );
+ for ( int i = 0; i < 2; ++i)
+ {
+ PointIndex &ip = *ipp[i];
+ ip = geom.vmap.FindIndex ( v[i] ) + dpi;
+ if ( ip == dpi || ip > nvertices + dpi )
+ {
+ PointIndex iv = ip;
+ if ( ip == dpi )
+ ip = iv = const_cast<OCCGeometry&>(geom).vmap.Add( v[i] );
+ gp_Pnt pnt = BRep_Tool::Pnt( v[i] );
+ MeshPoint mp( Point<3>(pnt.X(), pnt.Y(), pnt.Z()) );
+ for (PointIndex pi = 1; pi < first_vp; pi++)
+ if ( Dist2 (mesh.Point(pi), Point<3>(mp)) < 1e-100 )
+ {
+ ip = pi;
+ if ( mesh.Point(ip).GetLayer() != dfltP.GetLayer() && mesh.Point(ip).GetLayer() != iv )
+ continue;
+ if ( mesh.Point(ip).GetLayer() == dfltP.GetLayer())
+ mesh.Point(ip) = MeshPoint( mesh.Point(ip), iv );
+ break;
+ }
+ }
+ else
+ {
+ ip += first_vp - 1;
+ }
+ }
}
else
{
- Point<3> fp = occ2ng (BRep_Tool::Pnt (TopExp::FirstVertex (edge)));
- Point<3> lp = occ2ng (BRep_Tool::Pnt (TopExp::LastVertex (edge)));
+ TopoDS_Iterator vIt( edge, false );
+ TopoDS_Vertex v1 = TopoDS::Vertex( vIt.Value() ); vIt.Next();
+ TopoDS_Vertex v2 = TopoDS::Vertex( vIt.Value() );
+ if ( v1.Orientation() == TopAbs_REVERSED )
+ std::swap( v1, v2 );
+ const bool isClosedEdge = v1.IsSame( v2 );
+
+ Point<3> fp = occ2ng (BRep_Tool::Pnt (v1));
+ Point<3> lp = occ2ng (BRep_Tool::Pnt (v2));
+ double tol2 = std::min( eps*eps, 1e-6 * Dist2( fp, lp ));
+ if ( isClosedEdge )
+ tol2 = BRep_Tool::Tolerance( v1 ) * BRep_Tool::Tolerance( v1 );
pnums[0] = PointIndex::INVALID;
pnums.Last() = PointIndex::INVALID;
for (PointIndex pi : vertexrange)
{
- if (Dist2 (mesh[pi], fp) < eps*eps) pnums[0] = pi;
- if (Dist2 (mesh[pi], lp) < eps*eps) pnums.Last() = pi;
+ if (Dist2 (mesh[pi], fp) < tol2) pnums[0] = pi;
+ if (Dist2 (mesh[pi], lp) < tol2) pnums.Last() = pi;
}
- }
+ if (( isClosedEdge && pnums[0] != pnums.Last() ) ||
+ ( !isClosedEdge && pnums[0] == pnums.Last() ))
+ pnums[0] = pnums.Last() = PointIndex::INVALID;
+ if ( pnums[0] < PointIndex::BASE || pnums.Last() < PointIndex::BASE )
+ {
+ // take into account a possible large gap between a vertex and an edge curve
+ // end and a large vertex tolerance covering the whole edge
+ if ( pnums[0] < PointIndex::BASE )
+ {
+ double tol = BRep_Tool::Tolerance( v1 );
+ for (PointIndex pi = 1; pi < first_ep; pi++)
+ if (pi != pnums.Last() && Dist2 (mesh[pi], fp) < 2*tol*tol)
+ pnums[0] = pi;
+
+ if ( pnums[0] < PointIndex::BASE )
+ pnums[0] = first_ep-1 - nvertices + geom.vmap.FindIndex ( v1 );
+ }
+ if ( isClosedEdge )
+ {
+ pnums.Last() = pnums[0];
+ }
+ else
+ {
+ if ( pnums.Last() < PointIndex::BASE )
+ {
+ double tol = BRep_Tool::Tolerance( v2 );
+ for (PointIndex pi = 1; pi < first_ep; pi++)
+ if (pi != pnums[0] && Dist2 (mesh[pi], lp) < 2*tol*tol)
+ pnums.Last() = pi;
+
+ if ( pnums.Last() < PointIndex::BASE )
+ pnums.Last() = first_ep-1-nvertices + geom.vmap.FindIndex ( v2 );
+ }
+
+ if ( Dist2( fp, mesh[PointIndex(pnums[0])]) >
+ Dist2( lp, mesh[PointIndex(pnums.Last())]))
+ std::swap( pnums[0], pnums.Last() );
+ }
+ }
+ }
for (size_t i = 1; i <= mp.Size(); i++)
{
@@ -505,17 +594,19 @@ namespace netgen
// for (PointIndex j = first_ep; j < mesh.Points().End(); j++)
for (PointIndex j = first_ep; j < *mesh.Points().Range().end(); j++)
+ {
+ if (!merge_solids && mesh.Point(j).GetLayer() != geomedgenr ) continue;
if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
{
exists = true;
pnums[i] = j;
break;
}
-
+ }
tsearch.Stop();
if (!exists)
- pnums[i] = mesh.AddPoint (mp[i-1]);
+ pnums[i] = mesh.AddPoint (mp[i-1], geomedgenr);
}
if(geom.enames.Size() && geom.enames[curr-1] != "")
mesh.SetCD2Name(geomedgenr, geom.enames[curr-1]);
@@ -599,6 +690,9 @@ namespace netgen
// << " p1 " << mesh.LineSegment(i)[0] << " p2 " << mesh.LineSegment(i)[1] << endl;
// exit(10);
+ for (int j = 1; j <= mesh.GetNP(); j++) // support SALOME fuse edges: set level to zero
+ mesh.Point(j) = MeshPoint( (Point<3>&) mesh.Point(j) );
+
mesh.CalcSurfacesOfNode();
multithread.task = savetask;
}
@@ -652,7 +746,7 @@ namespace netgen
Box<3> bb = geom.GetBoundingBox();
- int projecttype = PLANESPACE;
+ //int projecttype = PLANESPACE;
static Timer tinit("init");
tinit.Start();
diff --git a/libsrc/occ/occmeshsurf.cpp b/libsrc/occ/occmeshsurf.cpp
index 7fa5d237..9e05fd95 100644
--- a/libsrc/occ/occmeshsurf.cpp
+++ b/libsrc/occ/occmeshsurf.cpp
@@ -173,50 +173,6 @@ namespace netgen
gp_Vec du, dv;
occface->D1 (geominfo1.u, geominfo1.v, pnt, du, dv);
- // static Timer t("occ-defintangplane calculations");
- // RegionTimer reg(t);
-
- Mat<3,2> D1_;
- D1_(0,0) = du.X(); D1_(1,0) = du.Y(); D1_(2,0) = du.Z();
- D1_(0,1) = dv.X(); D1_(1,1) = dv.Y(); D1_(2,1) = dv.Z();
- auto D1T_ = Trans(D1_);
- auto D1TD1_ = D1T_*D1_;
- if (Det (D1TD1_) == 0) throw SingularMatrixException();
- Mat<2,2> DDTinv_;
- CalcInverse (D1TD1_, DDTinv_);
-
- Mat<3,2> Y_;
- Vec<3> y1_ = (ap2-ap1).Normalize();
- Vec<3> y2_ = Cross(n, y1_).Normalize();
- for (int i = 0; i < 3; i++)
- {
- Y_(i,0) = y1_(i);
- Y_(i,1) = y2_(i);
- }
-
- auto A_ = DDTinv_ * D1T_ * Y_;
- Mat<2,2> Ainv_;
- if (Det(A_) == 0) throw SingularMatrixException();
- CalcInverse (A_, Ainv_);
-
- Vec<2> temp_ = Ainv_ * (psp2-psp1);
- double r_ = temp_.Length();
- Mat<2,2> R_;
- R_(0,0) = temp_(0)/r_;
- R_(1,0) = temp_(1)/r_;
- R_(0,1) = -R_(1,0);
- R_(1,1) = R_(0,0);
-
- A_ = A_ * R_;
- Ainv_ = Trans(R_) * Ainv_;
-
- Amat = A_;
- Amatinv = Ainv_;
-
- // temp = Amatinv * (psp2-psp1);
-
-
-#ifdef OLD
DenseMatrix D1(3,2), D1T(2,3), DDTinv(2,2);
D1(0,0) = du.X(); D1(1,0) = du.Y(); D1(2,0) = du.Z();
D1(0,1) = dv.X(); D1(1,1) = dv.Y(); D1(2,1) = dv.Z();
@@ -289,8 +245,7 @@ namespace netgen
}
// cout << "=?= Ainv = " << endl << Ainv << endl;
temp = Amatinv * (psp2-psp1);
- cout << " =?= Amatinv = " << Amatinv << endl;
-#endif
+ // cout << " =?= Amatinv = " << Amatinv << endl;
};
}
@@ -380,6 +335,7 @@ namespace netgen
double u = gi.u;
double v = gi.v;
+ if ( 0 ) { // exclude Newton's method
gp_Pnt x = occface->Value (u,v);
if (p.SquareDistance(x) <= sqr(PROJECTION_TOLERANCE)) return;
@@ -429,7 +385,7 @@ namespace netgen
}
}
while (count < 20);
-
+ }
// Newton did not converge, use OCC projection

View File

@ -1,4 +1,4 @@
# Copyright (C) 2012-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2012-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -17,22 +17,29 @@
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
INCLUDE(UseQtExt)
# --- options ---
# additional include directories
INCLUDE_DIRECTORIES(
${QT_INCLUDES}
${KERNEL_INCLUDE_DIRS}
${GUI_INCLUDE_DIRS}
${GEOM_INCLUDE_DIRS}
${OpenCASCADE_INCLUDE_DIR}
${NETGEN_INCLUDE_DIRS}
${SMESH_INCLUDE_DIRS}
${MEDCOUPLING_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${OMNIORB_INCLUDE_DIR}
${PROJECT_BINARY_DIR}/idl
)
#Avoid compilation warnings from netgen headers
INCLUDE_DIRECTORIES( SYSTEM ${NETGEN_INCLUDE_DIRS} ${NETGEN_ZLIB_INCLUDE_DIRS} )
# additional preprocessor / compiler flags
ADD_DEFINITIONS(
${QT_DEFINITIONS}
${OMNIORB_DEFINITIONS}
${OpenCASCADE_DEFINITIONS}
${BOOST_DEFINITIONS}
@ -61,7 +68,10 @@ SET(_link_LIBRARIES
${KERNEL_SalomeNS}
${KERNEL_SALOMELocalTrace}
${KERNEL_OpUtil}
VTK::CommonCore
VTK::CommonDataModel
SalomeIDLNETGENPLUGIN
Qt5::Core
)
# --- headers ---
@ -89,6 +99,14 @@ SET(NETGENEngine_HEADERS
NETGENPlugin_Mesher.hxx
NETGENPlugin_Remesher_2D.hxx
NETGENPlugin_Defs.hxx
NETGENPlugin_DriverParam.hxx
NETGENPlugin_NETGEN_3D_SA.hxx
NETGENPlugin_NETGEN_2D_SA.hxx
NETGENPlugin_NETGEN_1D2D3D_SA.hxx
NETGENPlugin_NETGEN_3D_Remote.hxx
NETGENPlugin_NETGEN_3D_Remote_i.hxx
NETGENPlugin_NETGEN_2D_Remote.hxx
NETGENPlugin_NETGEN_2D_Remote_i.hxx
)
# --- sources ---
@ -116,6 +134,18 @@ SET(NETGENEngine_SOURCES
NETGENPlugin_SimpleHypothesis_3D_i.cxx
NETGENPlugin_Remesher_2D.cxx
NETGENPlugin_i.cxx
NETGENPlugin_DriverParam.cxx
NETGENPlugin_NETGEN_3D_SA.cxx
NETGENPlugin_NETGEN_2D_SA.cxx
NETGENPlugin_NETGEN_1D2D3D_SA.cxx
NETGENPlugin_NETGEN_3D_Remote.cxx
NETGENPlugin_NETGEN_3D_Remote_i.cxx
NETGENPlugin_NETGEN_2D_Remote.cxx
NETGENPlugin_NETGEN_2D_Remote_i.cxx
)
SET(NetgenRunner_SOURCES
NETGENPlugin_Runner_main.cxx
)
# --- scripts ---
@ -132,6 +162,10 @@ ADD_LIBRARY(NETGENEngine ${NETGENEngine_SOURCES})
TARGET_LINK_LIBRARIES(NETGENEngine ${_link_LIBRARIES} )
INSTALL(TARGETS NETGENEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
ADD_EXECUTABLE(NETGENPlugin_Runner ${NetgenRunner_SOURCES})
TARGET_LINK_LIBRARIES(NETGENPlugin_Runner ${_link_LIBRARIES} NETGENEngine )
INSTALL(TARGETS NETGENPlugin_Runner EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
INSTALL(FILES ${NETGENEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
SALOME_INSTALL_SCRIPTS("${_bin_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/NETGENPlugin)

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -34,18 +34,22 @@ except ImportError:
LIBRARY = "libNETGENEngine.so"
NETGEN_VERSION_MAJOR = NETGENPlugin.NETGEN_VERSION_MAJOR
#----------------------------
# Mesh algo type identifiers
#----------------------------
## Algorithm type: Netgen tetrahedron 3D algorithm, see NETGEN_3D_Algorithm
NETGEN_3D = "NETGEN_3D"
NETGEN_3D_Remote = "NETGEN_3D_Remote"
## Algorithm type: Netgen tetrahedron 1D-2D-3D algorithm, see NETGEN_1D2D3D_Algorithm
NETGEN_1D2D3D = "NETGEN_2D3D"
## Algorithm type: Netgen triangle 1D-2D algorithm, see NETGEN_1D2D_Algorithm
NETGEN_1D2D = "NETGEN_2D"
## Algorithm type: Netgen triangle 2D algorithm, see NETGEN_2D_Only_Algorithm
NETGEN_2D = "NETGEN_2D_ONLY"
NETGEN_2D_Remote = "NETGEN_2D_Remote"
## Algorithm type: Synonim of NETGEN_1D2D3D, see NETGEN_1D2D3D_Algorithm
NETGEN_FULL = NETGEN_1D2D3D
## Algorithm type: Synonim of NETGEN_3D, see NETGEN_3D_Algorithm
@ -145,6 +149,12 @@ class NETGEN_Algorithm(Mesh_Algorithm):
if self.Parameters(): self.params.SetGrowthRate(theRate)
pass
## Sets @c NbThreads parameter
# @param theRate new value of the @c NbThreads parameter
def SetNbThreads(self, theNumber):
if self.Parameters(): self.params.SetNbThreads(theNumber)
pass
## Creates meshing hypothesis according to the chosen algorithm type
# and initializes it with default parameters
# @param which hypothesis type; can be either @ref SOLE (default) or @ref SIMPLE
@ -160,7 +170,7 @@ class NETGEN_Algorithm(Mesh_Algorithm):
hypType = "NETGEN_SimpleParameters_3D"
else:
hypType = "NETGEN_Parameters"
elif self.algoType == NETGEN_2D:
elif self.algoType in [NETGEN_2D, NETGEN_2D_Remote]:
hypType = "NETGEN_Parameters_2D_ONLY"
else:
hypType = "NETGEN_Parameters_3D"
@ -326,6 +336,7 @@ class NETGEN_1D2D_Algorithm(NETGEN_1D2D3D_Algorithm):
# @internal
docHelper = "Creates triangle 2D algorithm for faces"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
# @param geom geometry (shape/sub-shape) algorithm is assigned to;
@ -352,10 +363,15 @@ class NETGEN_2D_Only_Algorithm(NETGEN_Algorithm):
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = NETGEN_2D
## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
isDefault = True
## doc string of the method
# @internal
docHelper = "Creates triangle 2D algorithm for faces"
isDefault = True
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
# @param geom geometry (shape/sub-shape) algorithm is assigned to;
@ -465,6 +481,64 @@ class NETGEN_3D_Algorithm(NETGEN_Algorithm):
pass # end of NETGEN_3D_Algorithm class
## Tetrahedron 3D algorithm
#
# It can be created by calling smeshBuilder.Mesh.Tetrahedron() or smeshBuilder.Mesh.Tetrahedron( smeshBuilder.NETGEN, geom=0 )
#
# This algorithm generates only 3D (volumes) elements for given geometrical shape
# and, in contrast to NETGEN_1D2D3D_Algorithm class, should be used in conjunction
# with other 1D and 2D meshing algorithms.
class NETGEN_3D_Remote_Algorithm(NETGEN_3D_Algorithm):
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = NETGEN_3D_Remote
## flag pointing either this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = False
## doc string of the method
# @internal
docHelper = "Remotely Creates tetrahedron 3D algorithm for solids"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
# @param geom geometry (shape/sub-shape) algorithm is assigned to;
# if it is @c 0 (default), the algorithm is assigned to the main shape
def __init__(self, mesh, geom=0):
NETGEN_3D_Algorithm.__init__(self, mesh, geom)
pass
pass # end of NETGEN_3D_Remote_Algorithm class
## Tetrahedron 2D algorithm
#
# It can be created by calling smeshBuilder.Mesh.Triangle() or smeshBuilder.Mesh.Triangle( smeshBuilder.NETGEN, geom=0 )
#
class NETGEN_2D_Remote_Algorithm(NETGEN_2D_Only_Algorithm):
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = NETGEN_2D_Remote
## flag pointing either this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = False
## doc string of the method
# @internal
docHelper = "Remotely Creates triangles in face of solids"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
# @param geom geometry (shape/sub-shape) algorithm is assigned to;
# if it is @c 0 (default), the algorithm is assigned to the main shape
def __init__(self, mesh, geom=0):
self.algoType = NETGEN_2D_Remote
NETGEN_2D_Only_Algorithm.__init__(self, mesh, geom)
pass
pass # end of NETGEN_2D_Remote_Algorithm class
## Triangle (helper) 1D-2D algorithm
#

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -35,7 +35,7 @@
#define NETGENPLUGIN_EXPORT __declspec( dllimport )
#endif
#if defined(NETGEN_V5)
#if defined(NETGEN_V5) || defined(NETGEN_V6)
#define NETGENPLUGIN_DLL_HEADER DLL_HEADER
#else
#define NETGENPLUGIN_DLL_HEADER

View File

@ -0,0 +1,225 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : NETGENPlugin_DriverParam.hxx
// Author : Yoann AUDOUIN, EDF
// Module : NETGEN
//
#include "NETGENPlugin_DriverParam.hxx"
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
/**
* @brief Print content of a netgen_params
*
* @param aParams The object to display
*/
void printNetgenParams(netgen_params& aParams){
if ( aParams.myType == Hypo )
{
std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl;
std::cout << "maxh: " << aParams.maxh << std::endl;
std::cout << "minh: " << aParams.minh << std::endl;
std::cout << "segmentsperedge: " << aParams.segmentsperedge << std::endl;
std::cout << "grading: " << aParams.grading << std::endl;
std::cout << "curvaturesafety: " << aParams.curvaturesafety << std::endl;
std::cout << "secondorder: " << aParams.secondorder << std::endl;
std::cout << "quad: " << aParams.quad << std::endl;
std::cout << "optimize: " << aParams.optimize << std::endl;
std::cout << "fineness: " << aParams.fineness << std::endl;
std::cout << "uselocalh: " << aParams.uselocalh << std::endl;
std::cout << "merge_solids: " << aParams.merge_solids << std::endl;
std::cout << "chordalError: " << aParams.chordalError << std::endl;
std::cout << "optsteps2d: " << aParams.optsteps2d << std::endl;
std::cout << "optsteps3d: " << aParams.optsteps3d << std::endl;
std::cout << "elsizeweight: " << aParams.elsizeweight << std::endl;
std::cout << "opterrpow: " << aParams.opterrpow << std::endl;
std::cout << "delaunay: " << aParams.delaunay << std::endl;
std::cout << "checkoverlap: " << aParams.checkoverlap << std::endl;
std::cout << "checkchartboundary: " << aParams.checkchartboundary << std::endl;
std::cout << "closeedgefac: " << aParams.closeedgefac << std::endl;
std::cout << "nbThreadMesher: " << aParams.nbThreads << std::endl;
std::cout << "has_local_size: " << aParams.has_local_size << std::endl;
std::cout << "meshsizefilename: " << aParams.meshsizefilename << std::endl;
std::cout << "has_maxelementvolume_hyp: " << aParams.has_maxelementvolume_hyp << std::endl;
std::cout << "maxElementVolume: " << aParams.maxElementVolume << std::endl;
std::cout << "has_LengthFromEdges_hyp: " << aParams.has_LengthFromEdges_hyp << std::endl;
}
}
void importDefaultNetgenParams(const std::string param_file, netgen_params& aParams)
{
std::ifstream myfile(param_file);
std::string line;
// set the default type!
aParams.myType = Hypo;
std::getline(myfile, line);
aParams.has_netgen_param = std::stoi(line);
std::getline(myfile, line);
aParams.maxh = std::stod(line);
std::getline(myfile, line);
aParams.minh = std::stod(line);
std::getline(myfile, line);
aParams.segmentsperedge = std::stod(line);
std::getline(myfile, line);
aParams.grading = std::stod(line);
std::getline(myfile, line);
aParams.curvaturesafety = std::stod(line);
std::getline(myfile, line);
aParams.secondorder = std::stoi(line);
std::getline(myfile, line);
aParams.quad = std::stoi(line);
std::getline(myfile, line);
aParams.optimize = std::stoi(line);
std::getline(myfile, line);
aParams.fineness = std::stoi(line);
std::getline(myfile, line);
aParams.uselocalh = std::stoi(line);
std::getline(myfile, line);
aParams.merge_solids = std::stoi(line);
std::getline(myfile, line);
aParams.chordalError = std::stod(line);
std::getline(myfile, line);
aParams.optsteps2d = std::stoi(line);
std::getline(myfile, line);
aParams.optsteps3d = std::stoi(line);
std::getline(myfile, line);
aParams.elsizeweight = std::stod(line);
std::getline(myfile, line);
aParams.opterrpow = std::stoi(line);
std::getline(myfile, line);
aParams.delaunay = std::stoi(line);
std::getline(myfile, line);
aParams.checkoverlap = std::stoi(line);
std::getline(myfile, line);
aParams.checkchartboundary = std::stoi(line);
std::getline(myfile, line);
aParams.closeedgefac = std::stoi(line);
std::getline(myfile, line);
aParams.nbThreads = std::stoi(line);
std::getline(myfile, line);
aParams.has_local_size = std::stoi(line);
std::getline(myfile, line);
aParams.meshsizefilename = line;
std::getline(myfile, line);
aParams.has_maxelementvolume_hyp = std::stoi(line);
std::getline(myfile, line);
aParams.maxElementVolume = std::stod(line);
std::getline(myfile, line);
aParams.maxElementVolume = std::stoi(line);
myfile.close();
}
void importSimple2D3DNetgenParams(const std::string param_file, netgen_params& aParams, bool is3D )
{
std::ifstream myfile(param_file);
std::string line;
aParams.myType = !is3D ? Simple2D : Simple3D;
std::getline(myfile, line);
aParams.has_netgen_param = std::stoi(line); // 1
std::getline(myfile, line);
aParams.numberOfSegments = std::stoi(line); // segments (int)
std::getline(myfile, line);
aParams.localLength = std::stod(line); // localLenght (double)
std::getline(myfile, line);
aParams.maxElementArea = std::stod(line); // max area (double)
if ( is3D )
{
std::getline(myfile, line);
aParams.maxElementVol = std::stod(line); // max volume (double)
}
std::getline(myfile, line);
aParams.allowQuadrangles = std::stoi(line); // int
myfile.close();
};
/**
* @brief Import a param_file into a netgen_params structure
*
* @param param_file Name of the file
* @param aParams Structure to fill
*/
void importNetgenParams(const std::string param_file, netgen_params& aParams){
if ( param_file.find("simple2D") != std::string::npos || param_file.find("simple3D") != std::string::npos /*support simple 2D && 3D*/ )
{
importSimple2D3DNetgenParams( param_file, aParams, bool(param_file.find("simple3D") != std::string::npos) );
}
else if ( param_file.find("maxarea") == std::string::npos && param_file.find("lenghtfromedge") == std::string::npos /*hypo file for 2D SA*/)
{
importDefaultNetgenParams( param_file, aParams );
}
else
{
aParams.has_netgen_param = false;
}
};
/**
* @brief Writes the content of a netgen_param into a file
*
* @param param_file the file
* @param aParams the object
*/
void exportNetgenParams(const std::string param_file, netgen_params& aParams){
if ( aParams.myType == Hypo ){
std::ofstream myfile(param_file);
myfile << aParams.has_netgen_param << std::endl;
myfile << aParams.maxh << std::endl;
myfile << aParams.minh << std::endl;
myfile << aParams.segmentsperedge << std::endl;
myfile << aParams.grading << std::endl;
myfile << aParams.curvaturesafety << std::endl;
myfile << aParams.secondorder << std::endl;
myfile << aParams.quad << std::endl;
myfile << aParams.optimize << std::endl;
myfile << aParams.fineness << std::endl;
myfile << aParams.uselocalh << std::endl;
myfile << aParams.merge_solids << std::endl;
myfile << aParams.chordalError << std::endl;
myfile << aParams.optsteps2d << std::endl;
myfile << aParams.optsteps3d << std::endl;
myfile << aParams.elsizeweight << std::endl;
myfile << aParams.opterrpow << std::endl;
myfile << aParams.delaunay << std::endl;
myfile << aParams.checkoverlap << std::endl;
myfile << aParams.checkchartboundary << std::endl;
myfile << aParams.closeedgefac << std::endl;
myfile << aParams.nbThreads << std::endl;
myfile << aParams.has_local_size << std::endl;
myfile << aParams.meshsizefilename << std::endl;
myfile << aParams.has_maxelementvolume_hyp << std::endl;
myfile << aParams.maxElementVolume << std::endl;
myfile << aParams.has_LengthFromEdges_hyp << std::endl;
}
else if ( aParams.myType == Simple2D )
{
// TODO: Export the 2D && 3D simple versions
}
};

View File

@ -0,0 +1,99 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : NETGENPlugin_DriverParam.hxx
// Author : Yoann AUDOUIN, EDF
// Module : NETGEN
//
#ifndef _NETGENPLUGIN_DRIVERPARAM_HXX_
#define _NETGENPLUGIN_DRIVERPARAM_HXX_
#include <string>
enum hypoType{
Hypo = 1, /*the default hypo common for 1D2D,1D2D3D && 3D*/
Simple2D,
Simple3D
};
struct netgen_params{
// Params from NETGENPlugin_Mesher
// True if _hypParameters is not null
bool has_netgen_param=true;
hypoType myType;
double maxh;
double minh;
double segmentsperedge;
double grading;
double curvaturesafety;
int secondorder;
int quad;
bool optimize;
int fineness;
bool uselocalh;
bool merge_solids;
double chordalError;
int optsteps2d;
int optsteps3d;
double elsizeweight;
int opterrpow;
bool delaunay;
bool checkoverlap;
bool checkchartboundary;
int closeedgefac;
// Number of threads for the mesher
int nbThreads;
// True if we have a mesh size file or local size info
bool has_local_size = false;
std::string meshsizefilename;
// Params from NETGEN3D
// True if _hypMaxElementVolume is not null
bool has_maxelementvolume_hyp=false;
double maxElementVolume=0.0;
// Params from NETGEN2D
bool has_LengthFromEdges_hyp=false;
/////////////////////////////////////
// Quantities proper of Simple2D
int numberOfSegments; // maybe reuse segmentsperedge (?)
double localLength;
double maxElementArea;
bool allowQuadrangles;
//// Quantities proper of Simple3D
double maxElementVol;
};
void printNetgenParams(netgen_params& aParams);
void importNetgenParams(const std::string param_file, netgen_params& aParams);
void importDefaultNetgenParams(const std::string param_file, netgen_params& aParams);
void importSimple2D3DNetgenParams(const std::string param_file, netgen_params& aParams, bool is3D );
void exportNetgenParams(const std::string param_file, netgen_params& aParams);
// TODO symple param to be used with netgen1d2d
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -58,6 +58,7 @@ NETGENPlugin_Hypothesis::NETGENPlugin_Hypothesis (int hypId, SMESH_Gen * gen)
_nbVolOptSteps (GetDefaultNbVolOptSteps()),
_elemSizeWeight (GetDefaultElemSizeWeight()),
_worstElemMeasure (GetDefaultWorstElemMeasure()),
_nbThreads (GetDefaultNbThreads()),
_surfaceCurvature (GetDefaultSurfaceCurvature()),
_useDelauney (GetDefaultUseDelauney()),
_checkOverlapping (GetDefaultCheckOverlapping()),
@ -436,6 +437,20 @@ void NETGENPlugin_Hypothesis::SetCheckChartBoundary( bool theVal )
}
}
//=======================================================================
//function : SetNbThreads
//purpose :
//=======================================================================
void NETGENPlugin_Hypothesis::SetNbThreads( int theVal )
{
if (theVal != _nbThreads)
{
_nbThreads = theVal;
NotifySubMeshesHypothesisModification();
}
}
//=============================================================================
/*!
*
@ -642,8 +657,8 @@ istream & NETGENPlugin_Hypothesis::LoadFrom(istream & load)
* \retval bool - always false
*/
//================================================================================
bool NETGENPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh,
const TopoDS_Shape& theShape)
bool NETGENPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -35,6 +35,7 @@
#include "Utils_SALOME_Exception.hxx"
#include <map>
#include <thread>
// Parameters for work of NETGEN
//
@ -125,6 +126,9 @@ public:
void SetCheckChartBoundary( bool toCheck );
bool GetCheckChartBoundary() const { return _checkChartBoundary; }
void SetNbThreads( int val );
int GetNbThreads() const { return _nbThreads; }
// the default values (taken from NETGEN 4.5 sources)
static Fineness GetDefaultFineness() { return Moderate; }
@ -145,6 +149,7 @@ public:
static bool GetDefaultCheckOverlapping() { return true; }
static bool GetDefaultCheckChartBoundary(){ return true; }
static bool GetDefaultFuseEdges() { return true; }
static int GetDefaultNbThreads() { return std::thread::hardware_concurrency(); }
// Persistence
virtual std::ostream & SaveTo (std::ostream & save);
@ -197,6 +202,9 @@ private:
//bool _blockFilling; -- not used by netgen
// (SALOME additions)
bool _fuseEdges;
// Parallelism parameters
int _nbThreads;
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -337,7 +337,6 @@ CORBA::Double NETGENPlugin_Hypothesis_i::GetChordalError()
void NETGENPlugin_Hypothesis_i::SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj,
CORBA::Double localSize)
throw (SALOME::SALOME_Exception)
{
string entry;
entry = GeomObj->GetStudyEntry();
@ -374,7 +373,7 @@ NETGENPlugin::string_array* NETGENPlugin_Hypothesis_i::GetLocalSizeEntries()
NETGENPlugin::string_array_var result = new NETGENPlugin::string_array();
const ::NETGENPlugin_Hypothesis::TLocalSize localSizes =
this->GetImpl()->GetLocalSizesAndEntries();
result->length(localSizes.size());
result->length((CORBA::ULong) localSizes.size());
::NETGENPlugin_Hypothesis::TLocalSize::const_iterator it = localSizes.begin();
for (int i=0 ; it != localSizes.end() ; i++, it++)
{
@ -491,7 +490,7 @@ void NETGENPlugin_Hypothesis_i::SetNbSurfOptSteps(CORBA::Short nb )
CORBA::Short NETGENPlugin_Hypothesis_i::GetNbSurfOptSteps()
{
return GetImpl()->GetNbSurfOptSteps();
return (CORBA::Short) GetImpl()->GetNbSurfOptSteps();
}
//=======================================================================
@ -516,7 +515,7 @@ void NETGENPlugin_Hypothesis_i::SetNbVolOptSteps(CORBA::Short nb )
CORBA::Short NETGENPlugin_Hypothesis_i::GetNbVolOptSteps()
{
return GetImpl()->GetNbVolOptSteps();
return (CORBA::Short) GetImpl()->GetNbVolOptSteps();
}
//=======================================================================
@ -564,7 +563,31 @@ void NETGENPlugin_Hypothesis_i::SetWorstElemMeasure(CORBA::Short val )
CORBA::Short NETGENPlugin_Hypothesis_i::GetWorstElemMeasure()
{
return GetImpl()->GetWorstElemMeasure();
return (CORBA::Short) GetImpl()->GetWorstElemMeasure();
}
//=======================================================================
//function : SetNbThreads
//purpose :
//=======================================================================
void NETGENPlugin_Hypothesis_i::SetNbThreads(CORBA::Short val )
{
if ( GetNbThreads() != val )
{
this->GetImpl()->SetNbThreads( val );
SMESH::TPythonDump() << _this() << ".SetNbThreads( " << SMESH::TVar(val) << " )";
}
}
//=======================================================================
//function : GetNbThreads
//purpose :
//=======================================================================
CORBA::Short NETGENPlugin_Hypothesis_i::GetNbThreads()
{
return (CORBA::Short) GetImpl()->GetNbThreads();
}
//=======================================================================
@ -712,7 +735,7 @@ std::string NETGENPlugin_Hypothesis_i::getMethodOfParameter(const int paramIndex
bool
NETGENPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const
std::vector< int > & /*subIDArray*/ ) const
{
typedef ::NETGENPlugin_Hypothesis THyp;
@ -734,7 +757,7 @@ NETGENPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entr
bool
NETGENPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray )
std::vector< int > & /*subIDArray*/ )
{
typedef ::NETGENPlugin_Hypothesis THyp;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -83,8 +83,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
void SetChordalError(CORBA::Double value);
CORBA::Double GetChordalError();
void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize)
throw (SALOME::SALOME_Exception);
void SetLocalSizeOnShape(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double localSize);
void SetLocalSizeOnEntry(const char* entry, CORBA::Double localSize);
CORBA::Double GetLocalSizeOnEntry(const char* entry);
NETGENPlugin::string_array* GetLocalSizeEntries();
@ -114,6 +113,9 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Hypothesis_i:
void SetWorstElemMeasure(CORBA::Short val );
CORBA::Short GetWorstElemMeasure();
void SetNbThreads(CORBA::Short val );
CORBA::Short GetNbThreads();
void SetUseDelauney(CORBA::Boolean toUse);
CORBA::Boolean GetUseDelauney();

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -35,9 +35,18 @@
#include <SMDS_MeshElement.hxx>
#include <SMESH_Algo.hxx>
#include <SMESH_ProxyMesh.hxx>
#include <SALOMEDS_Tool.hxx>
#include "Basics_Utils.hxx"
#include "SALOME_Basics.hxx"
#include <TopTools_IndexedMapOfShape.hxx>
// Netgen include files
#ifndef OCCGEOMETRY
#define OCCGEOMETRY
#endif
#include <occgeom.hpp>
#include <meshing.hpp>
namespace nglib {
#include <nglib.h>
}
@ -58,7 +67,35 @@ class TopoDS_Shape;
namespace netgen {
class OCCGeometry;
class Mesh;
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
}
// Class for temporary folder switching
class ChdirRAII
{
public:
#ifndef WIN32
ChdirRAII(const std::string& wd):_wd(wd) { if(_wd.empty()) return ; char *pwd(get_current_dir_name()); _od = pwd; free(pwd); chdir(_wd.c_str()); }
~ChdirRAII() { if(_od.empty()) return ; chdir(_od.c_str()); }
#else
ChdirRAII(const std::string& wd) : _wd(wd) {
if (_wd.empty())
return;
TCHAR pwd[MAX_PATH];
GetCurrentDirectory(sizeof(pwd), pwd);
_od = Kernel_Utils::utf8_encode_s(pwd);
SetCurrentDirectory(Kernel_Utils::utf8_decode_s(_wd).c_str());
}
~ChdirRAII() {
if (_od.empty()) return;
SetCurrentDirectory(Kernel_Utils::utf8_decode_s(_od).c_str());
}
#endif
private:
std::string _wd;
std::string _od;
};
//=============================================================================
/*!
* \brief Struct storing nb of entities in netgen mesh
@ -85,19 +122,35 @@ struct NETGENPlugin_ngMeshInfo
struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
{
bool _isComputeOk;
nglib::Ng_Mesh * _ngMesh;
netgen::Mesh * _ngMesh;
NETGENPlugin_NetgenLibWrapper();
~NETGENPlugin_NetgenLibWrapper();
void setMesh( nglib::Ng_Mesh* mesh );
nglib::Ng_Mesh* ngMesh() { return (nglib::Ng_Mesh*)(void*)_ngMesh; }
static int GenerateMesh(netgen::OCCGeometry& occgeo, int startWith, int endWith,
netgen::Mesh* & ngMesh);
int GenerateMesh(netgen::OCCGeometry& occgeo, int startWith, int endWith )
{
return GenerateMesh( occgeo, startWith, endWith, _ngMesh );
}
static void CalcLocalH( netgen::Mesh * ngMesh );
static void RemoveTmpFiles();
static int& instanceCounter();
void setOutputFile(std::string);
private:
std::string getOutputFileName();
void removeOutputFile();
std::string _outputFileName;
// This will change current directory when the class is instanciated and switch
ChdirRAII _tmpDir;
ostream * _ngcout;
ostream * _ngcerr;
@ -128,7 +181,56 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
void SetLocalSizeForChordalError( netgen::OCCGeometry& occgeo, netgen::Mesh& ngMesh );
static void SetLocalSize( netgen::OCCGeometry& occgeo, netgen::Mesh& ngMesh );
/**
* @brief InitialSetup. Fill occgeo map with geometrical objects not meshed. Fill meshdSM with the already computed
* submeshes, and mesh the internal edges so faces with internal are eventurally properly meshed.
* Define the class members _ngMesh and _occgeom
*/
void InitialSetup( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo,
list< SMESH_subMesh* >* meshedSM, NETGENPlugin_Internals* internals,
SMESH_MesherHelper &quadHelper, NETGENPlugin_ngMeshInfo& initState, netgen::MeshingParameters &mparams );
void InitialSetupSA( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo,
list< SMESH_subMesh* >* meshedSM, NETGENPlugin_Internals* internals,
SMESH_MesherHelper &quadHelper, NETGENPlugin_ngMeshInfo& initState,
netgen::MeshingParameters &mparams, bool useFMapFunction = false );
void SetBasicMeshParameters( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo );
void SetBasicMeshParametersFor2D( netgen::OCCGeometry& occgeo, vector< const SMDS_MeshNode* >& nodeVec,
netgen::MeshingParameters &mparams, NETGENPlugin_Internals* internals,
NETGENPlugin_ngMeshInfo& initState );
void SetBasicMeshParametersFor3D( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo,
vector< const SMDS_MeshNode* >& nodeVec, netgen::MeshingParameters &mparams,
NETGENPlugin_Internals* internals, NETGENPlugin_ngMeshInfo& initState, SMESH_MesherHelper &quadHelper,
SMESH_Comment& comment );
void CallNetgenConstAnalysis( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo );
int CallNetgenMeshEdges( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo );
int CallNetgenMeshFaces( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo, SMESH_Comment& comment );
int CallNetgenMeshVolumens( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo, SMESH_Comment& comment );
void MakeSecondOrder( netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo,
list< SMESH_subMesh* >* meshedSM, NETGENPlugin_ngMeshInfo& initState, SMESH_Comment& comment );
int FillInternalElements( NETGENPlugin_NetgenLibWrapper& ngLib, NETGENPlugin_Internals& internals, netgen::OCCGeometry& occgeo,
NETGENPlugin_ngMeshInfo& initState, SMESH_MesherHelper &quadHelper, list< SMESH_subMesh* >* meshedSM );
bool Fill2DViscousLayer( netgen::OCCGeometry& occgeo, vector< const SMDS_MeshNode* >& nodeVec,
NETGENPlugin_Internals* internals, NETGENPlugin_ngMeshInfo& initState );
bool Fill3DViscousLayerAndQuadAdaptor( netgen::OCCGeometry& occgeo, vector< const SMDS_MeshNode* >& nodeVec,
netgen::MeshingParameters &mparams, NETGENPlugin_ngMeshInfo& initState,
list< SMESH_subMesh* >* meshedSM, SMESH_MesherHelper &quadHelper, int & err );
int Fill0D1DElements( netgen::OCCGeometry& occgeo, vector< const SMDS_MeshNode* >& nodeVec, list< SMESH_subMesh* >* meshedSM, SMESH_MesherHelper &quadHelper );
void FillSMESH( netgen::OCCGeometry& occgeo, NETGENPlugin_ngMeshInfo& initState, vector< const SMDS_MeshNode* >& nodeVec, SMESH_MesherHelper &quadHelper, SMESH_Comment& comment );
///// End definition methods to rewrite function
enum DIM {
D1 = 1,
D2,
D3
};
bool Compute();
bool Compute( NETGENPlugin_NetgenLibWrapper& ngLib, vector< const SMDS_MeshNode* >& nodeVec, bool write2SMESH, DIM dim );
bool Evaluate(MapShapeNbElems& aResMap);
@ -200,6 +302,19 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
private:
bool Compute1D( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo );
bool Compute2D( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo,
netgen::MeshingParameters &mparams, list< SMESH_subMesh* >* meshedSM,
NETGENPlugin_ngMeshInfo& initState, NETGENPlugin_Internals* internals,
vector< const SMDS_MeshNode* >& nodeVec, SMESH_Comment& comment, DIM dim );
bool Compute3D( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo,
netgen::MeshingParameters &mparams, list< SMESH_subMesh* >* meshedSM,
NETGENPlugin_ngMeshInfo& initState, NETGENPlugin_Internals* internals,
vector< const SMDS_MeshNode* >& nodeVec, SMESH_MesherHelper &quadHelper,
SMESH_Comment& comment);
SMESH_Mesh* _mesh;
const TopoDS_Shape& _shape;
bool _isVolume;

View File

@ -0,0 +1,386 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// NETGENPlugin : C++ implementation
// File : NETGENPlugin_NETGEN_2D3D_SA.cxx
// Author : Cesar Conopoima (OCC)
// Date : 01/11/2023
// Project : SALOME
//=============================================================================
//
#include "NETGENPlugin_DriverParam.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
#include "NETGENPlugin_SimpleHypothesis_3D.hxx"
#include "NETGENPlugin_NETGEN_2D.hxx"
#include "NETGENPlugin_NETGEN_1D2D3D_SA.hxx"
#include <SMESHDS_Mesh.hxx>
#include <SMESH_ControlsDef.hxx>
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_MesherHelper.hxx>
#include <SMESH_DriverShape.hxx>
#include <SMESH_DriverMesh.hxx>
#include <utilities.h>
#include <list>
namespace nglib {
#include <nglib.h>
}
#include <meshing.hpp>
using namespace nglib;
//=============================================================================
/*!
*
*/
//=============================================================================
NETGENPlugin_NETGEN_1D2D3D_SA::NETGENPlugin_NETGEN_1D2D3D_SA()
: NETGENPlugin_NETGEN_2D3D(0, new SMESH_Gen())
{
_name = "NETGEN_1D2D3D_SA";
}
//=============================================================================
/*!
*
*/
//=============================================================================
NETGENPlugin_NETGEN_1D2D3D_SA::~NETGENPlugin_NETGEN_1D2D3D_SA()
{
}
/**
* @brief Check presence and content of orientation file. Implemented for completness and future reference.
*
* @param element_orientation_file Binary file containing the orientation of surface elemnts
* @return true, false
*/
bool NETGENPlugin_NETGEN_1D2D3D_SA::checkOrientationFile( const std::string element_orientation_file )
{
if(element_orientation_file.empty()){
MESSAGE("No element orientation file");
return true;
} else {
MESSAGE("Reading from elements from file: " << element_orientation_file);
// By construction the orientation file written by Remote version has a zero written to mark no need of orientation in 2D meshing
int nbElement;
std::ifstream df(element_orientation_file, ios::binary|ios::in);
df.read((char*)&nbElement, sizeof(int));
df.close();
return (nbElement == 0);
}
}
/**
* @brief fill plugin hypothesis from the netgen_params structure
*
* @param aParams the structure
*/
void NETGENPlugin_NETGEN_1D2D3D_SA::fillHyp(netgen_params aParams)
{
if( aParams.myType == hypoType::Hypo )
{
NETGENPlugin_Hypothesis * hypParameters = new NETGENPlugin_Hypothesis(0, GetGen());
hypParameters->SetMaxSize(aParams.maxh);
hypParameters->SetMinSize(aParams.minh);
hypParameters->SetNbSegPerEdge(aParams.segmentsperedge);
hypParameters->SetGrowthRate(aParams.grading);
hypParameters->SetNbSegPerRadius(aParams.curvaturesafety);
hypParameters->SetSecondOrder(aParams.secondorder);
hypParameters->SetQuadAllowed(aParams.quad);
hypParameters->SetOptimize(aParams.optimize);
hypParameters->SetFineness((NETGENPlugin_Hypothesis::Fineness)aParams.fineness);
hypParameters->SetSurfaceCurvature(aParams.uselocalh);
hypParameters->SetFuseEdges(aParams.merge_solids);
hypParameters->SetChordalErrorEnabled(aParams.chordalError);
if(aParams.optimize){
hypParameters->SetNbSurfOptSteps(aParams.optsteps2d);
hypParameters->SetNbVolOptSteps(aParams.optsteps3d);
}
hypParameters->SetElemSizeWeight(aParams.elsizeweight);
hypParameters->SetWorstElemMeasure(aParams.opterrpow);
hypParameters->SetUseDelauney(aParams.delaunay);
hypParameters->SetCheckOverlapping(aParams.checkoverlap);
hypParameters->SetCheckChartBoundary(aParams.checkchartboundary);
hypParameters->SetMeshSizeFile(aParams.meshsizefilename);
_hypothesis = dynamic_cast< const NETGENPlugin_Hypothesis *> (hypParameters);
}
else if ( aParams.myType == hypoType::Simple2D )
{
NETGENPlugin_SimpleHypothesis_2D * hypParameters = new NETGENPlugin_SimpleHypothesis_2D(0, GetGen());
// mandatory to fill in this branch case!
// Number of segments (int)
// localLenght (double)
// maxElement area (double)
// GetAllowQuadrangles (bool)
hypParameters->SetNumberOfSegments( aParams.numberOfSegments );
if ( !aParams.numberOfSegments )
hypParameters->SetLocalLength( aParams.localLength );
hypParameters->SetMaxElementArea( aParams.maxElementArea );
hypParameters->SetAllowQuadrangles( aParams.allowQuadrangles );
_hypothesis = dynamic_cast< const NETGENPlugin_SimpleHypothesis_2D *> (hypParameters);
}
else if ( aParams.myType == hypoType::Simple3D )
{
NETGENPlugin_SimpleHypothesis_3D * hypParameters = new NETGENPlugin_SimpleHypothesis_3D(0, GetGen());
// mandatory to fill in this branch case!
// Number of segments (int)
// localLenght (double)
// maxElement area (double)
// maxElement volume (double)
// GetAllowQuadrangles (bool)
hypParameters->SetNumberOfSegments( aParams.numberOfSegments );
if ( !aParams.numberOfSegments )
hypParameters->SetLocalLength( aParams.localLength );
hypParameters->SetMaxElementArea( aParams.maxElementArea );
hypParameters->SetMaxElementVolume( aParams.maxElementVol );
hypParameters->SetAllowQuadrangles( aParams.allowQuadrangles );
_hypothesis = dynamic_cast< const NETGENPlugin_SimpleHypothesis_3D *> (hypParameters);
}
}
/**
* @brief Write a binary file containing information on the elements/nodes
* created by the netgen mesher
*
* @param nodeVec mapping between the mesh id and the netgen structure id
* @param ngLib Wrapper on netgen library
* @param new_element_file Name of the output file
* @param NumOfPremeshedNodes Number of nodes in the netgen structure
* @return true if there are some error
*/
bool NETGENPlugin_NETGEN_1D2D3D_SA::FillNewElementFile( std::vector< const SMDS_MeshNode* > &nodeVec, NETGENPlugin_NetgenLibWrapper &ngLib,
std::string new_element_file, const NETGENPlugin_Mesher::DIM dim )
{
// Particularities: As submeshing is not supported nodeVect is empty and NumberOfPremeshedNodes is also zero
Ng_Mesh* NetgenMesh = ngLib.ngMesh();
int NetgenNodes = Ng_GetNP(NetgenMesh);
int NetgenSeg2D = Ng_GetNSeg_2D( NetgenMesh );
int NetgenFaces = Ng_GetNSE(NetgenMesh);
int NetgenVols = Ng_GetNE(NetgenMesh);
int segmentId;
bool isOK = ( NetgenNodes > 0 && NetgenSeg2D > 0 );
if ( isOK && !new_element_file.empty() )
{
MESSAGE("Writting new elements")
std::ofstream df(new_element_file, ios::out|ios::binary);
double NetgenPoint[3];
int NetgenSegment[2];
int NetgenSurface[8];
int NetgenVolumens[10];
// Writing nodevec (correspondence netgen numbering mesh numbering)
// Number of nodes
const int NumOfPremeshedNodes = nodeVec.size();
df.write((char*) &NumOfPremeshedNodes, sizeof(int));
df.write((char*) &NetgenNodes, sizeof(int));
for (int nodeIndex = 1 ; nodeIndex <= NumOfPremeshedNodes; ++nodeIndex )
{
//Id of the point
int id = nodeVec.at(nodeIndex)->GetID();
df.write((char*) &id, sizeof(int));
}
// Writing all new points
for (int nodeIndex = NumOfPremeshedNodes + 1; nodeIndex <= NetgenNodes; ++nodeIndex )
{
Ng_GetPoint( NetgenMesh, nodeIndex, NetgenPoint );
// Coordinates of the point
df.write((char *) &NetgenPoint, sizeof(double)*3);
}
if ( dim >= NETGENPlugin_Mesher::D1 )
{
// create segments at boundaries.
df.write((char*) &NetgenSeg2D, sizeof(int));
for ( int elemIndex = 1; elemIndex <= NetgenSeg2D; ++elemIndex )
{
Ng_GetSegment_2D( NetgenMesh, elemIndex, NetgenSegment, &segmentId );
df.write((char*) &NetgenSegment, sizeof(int) * 2 );
}
}
if ( dim >= NETGENPlugin_Mesher::D2 )
{
// create surface elements.
df.write((char*) &NetgenFaces, sizeof(int));
for ( int elemIndex = 1; elemIndex <= NetgenFaces; ++elemIndex )
{
nglib::Ng_Surface_Element_Type elemType = Ng_GetSurfaceElement( NetgenMesh, elemIndex, NetgenSurface );
switch (elemType)
{
case nglib::NG_TRIG:
{
df.write((char*) &NetgenSurface, sizeof(int) * 3 );
break;
}
case nglib::NG_QUAD:
{
df.write((char*) &NetgenSurface, sizeof(int) * 4 );
break;
}
case nglib::NG_TRIG6:
{
df.write((char*) &NetgenSurface, sizeof(int) * 6 );
break;
}
case nglib::NG_QUAD8:
{
df.write((char*) &NetgenSurface, sizeof(int) * 8 );
break;
}
default:
{ break; }
}
}
}
if ( dim >= NETGENPlugin_Mesher::D3 )
{
// create volume elements.
df.write((char*) &NetgenVols, sizeof(int));
for ( int elemIndex = 1; elemIndex <= NetgenVols; ++elemIndex )
{
nglib::Ng_Volume_Element_Type elemType = Ng_GetVolumeElement( NetgenMesh, elemIndex, NetgenVolumens );
switch (elemType)
{
case nglib::NG_TET:
{
df.write((char*) &NetgenVolumens, sizeof(int) * 4 );
break;
}
case nglib::NG_PYRAMID:
{
df.write((char*) &NetgenVolumens, sizeof(int) * 5 );
break;
}
case nglib::NG_PRISM:
{
df.write((char*) &NetgenVolumens, sizeof(int) * 6 );
break;
}
case nglib::NG_TET10:
{
df.write((char*) &NetgenVolumens, sizeof(int) * 10 );
break;
}
default:
{ break; }
}
}
}
df.close();
}
return false;
}
/**
* @brief Compute the mesh based on the
*
* @param aMesh the read Mesh
* @param aShape the loaded shape
* @param new_element_file output file containing info the elements created by the mesher
* @param output_mesh whether or not write the created elements into the mesh
* @param dim the dimension to be meshed.
* @return negation of mesh fail: true, false
*/
bool NETGENPlugin_NETGEN_1D2D3D_SA::Compute(SMESH_Mesh& aMesh, TopoDS_Shape &aShape, std::string new_element_file, bool output_mesh, NETGENPlugin_Mesher::DIM dim )
{
//
netgen::multithread.terminate = 0;
NETGENPlugin_Mesher mesher(&aMesh, aShape, /*is3D = */ false );
mesher.SetParameters(dynamic_cast<const NETGENPlugin_Hypothesis*>(_hypothesis));
if ( dim == NETGENPlugin_Mesher::D3 )
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_3D*>(_hypothesis));
else
mesher.SetParameters(dynamic_cast<const NETGENPlugin_SimpleHypothesis_2D*>(_hypothesis));
NETGENPlugin_NetgenLibWrapper ngLib;
vector< const SMDS_MeshNode* > nodeVec;
bool err = mesher.Compute( ngLib, nodeVec, output_mesh, dim );
FillNewElementFile( nodeVec, ngLib, new_element_file, dim );
return err;
}
/**
* @brief Running the mesher on the given files
*
* @param input_mesh_file Mesh file (containing 2D elements)
* @param shape_file Shape file (BREP or STEP format)
* @param hypo_file Ascii file containing the netgen parameters
* @param element_orientation_file Binary file containing the orientation of surface elemnts
* @param new_element_file output file containing info the elements created by the mesher
* @param output_mesh_file output mesh file (if empty it will not be created)
* @return negation of mesh fail: true, false
*/
int NETGENPlugin_NETGEN_1D2D3D_SA::run(const std::string input_mesh_file,
const std::string shape_file,
const std::string hypo_file,
const std::string element_orientation_file,
const std::string new_element_file,
const std::string output_mesh_file,
const NETGENPlugin_Mesher::DIM dim )
{
// _element_orientation_file = element_orientation_file;
std::unique_ptr<SMESH_Mesh> myMesh(_gen->CreateMesh(false));
// Importing mesh
SMESH_DriverMesh::importMesh(input_mesh_file, *myMesh);
// Importing shape
TopoDS_Shape myShape;
SMESH_DriverShape::importShape(shape_file, myShape);
// Importing hypothesis
netgen_params myParams;
importNetgenParams(hypo_file, myParams);
fillHyp(myParams);
int ret = 1;
if ( checkOrientationFile(element_orientation_file) )
{
ret = Compute( *myMesh, myShape, new_element_file, !output_mesh_file.empty(), dim );
if(ret){
std::cerr << "Meshing failed" << std::endl;
return ret;
}
if(!output_mesh_file.empty()){
std::string meshName = "MESH";
SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
}
}
else
std::cerr << "For NETGENPlugin_NETGEN_1D2D3D_SA, orientation file should be market with 0 or be empty!" << std::endl;
return ret;
}

View File

@ -0,0 +1,63 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// NETGENPlugin : C++ implementation
// File : NETGENPlugin_NETGEN_2D_SA.hxx
// Author : Cesar Conopoima (OCC)
// Date : 23/10/2023
// Project : SALOME
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_1D2D3D_SA_HXX_
#define _NETGENPlugin_NETGEN_1D2D3D_SA_HXX_
#include "NETGENPlugin_Defs.hxx"
#include "NETGENPlugin_Mesher.hxx"
#include "NETGENPlugin_NETGEN_2D3D.hxx"
#include "SMESH_Algo.hxx"
#include "SMESH_Mesh.hxx"
class NETGENPlugin_Mesher;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_1D2D3D_SA: public NETGENPlugin_NETGEN_2D3D
{
public:
NETGENPlugin_NETGEN_1D2D3D_SA();
virtual ~NETGENPlugin_NETGEN_1D2D3D_SA();
bool Compute(SMESH_Mesh& aMesh, TopoDS_Shape &aShape, std::string new_element_file, bool output_mesh, NETGENPlugin_Mesher::DIM dim );
int run(const std::string input_mesh_file,
const std::string shape_file,
const std::string hypo_file,
const std::string element_orientation_file,
const std::string new_element_file,
const std::string output_mesh_file,
const NETGENPlugin_Mesher::DIM dim );
private:
bool checkOrientationFile( const std::string element_orientation_file );
void fillHyp(netgen_params aParams);
bool FillNewElementFile( std::vector< const SMDS_MeshNode* > &nodeVec, NETGENPlugin_NetgenLibWrapper &ngLib,
std::string new_element_file, const NETGENPlugin_Mesher::DIM dim );
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -26,6 +26,10 @@
#include <SMESH_Algo.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_Group.hxx>
#include <SMESHDS_GroupBase.hxx>
#include "NETGENPlugin_Mesher.hxx"
class StdMeshers_MaxElementArea;
class StdMeshers_LengthFromEdges;
@ -59,6 +63,29 @@ public:
virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
bool MapSegmentsToEdges(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
NETGENPlugin_NetgenLibWrapper &ngLib,
vector< const SMDS_MeshNode* >& nodeVec,
std::map<int,const SMDS_MeshNode*>& premeshedNodes,
std::map<int,std::vector<double>>& newNetgenCoordinates,
std::map<int,std::vector<smIdType>>& newNetgenElements );
std::tuple<bool,bool> SetParameteres( SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
NETGENPlugin_Mesher& aMesher, netgen::Mesh * ngMeshes,
netgen::OCCGeometry& occgeoComm, bool isSubMeshSupported = true );
bool ComputeMaxhOfFace( TopoDS_Face& Face, NETGENPlugin_Mesher& aMesher, TSideVector& wires,
netgen::OCCGeometry& occgeoComm, bool isDefaultHyp, bool isCommonLocalSize );
void FillNodesAndElements( SMESH_Mesh& aMesh, SMESH_MesherHelper& helper, netgen::Mesh * ngMesh, vector< const SMDS_MeshNode* >& nodeVec, int faceId );
/*!
* \brief FillNodesAndElements, fill created triangular elements by netgen to the smesh data structure
*/
void FillNodesAndElements( SMESH_Mesh& aMesh, SMESH_MesherHelper& helper, netgen::Mesh * ngMesh, vector< const SMDS_MeshNode* >& nodeVec, map<int, const SMDS_MeshNode* >& ng2smesh,
std::map<int,std::vector<double>>& newNetgenCoordinates, std::map<int,std::vector<smIdType>>& newNetgenElements, const int numberOfPremeshedNodes );
protected:
const StdMeshers_MaxElementArea* _hypMaxElementArea;
const StdMeshers_LengthFromEdges* _hypLengthFromEdges;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -0,0 +1,350 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//=============================================================================
// File : NETGENPlugin_NETGEN_2D_Remote.cxx
// Created : mardi 12 Decembre 2023
// Author : Cesar Conopoima (OCC)
// Project : SALOME
//=============================================================================
//
//
#include "NETGENPlugin_NETGEN_2D_Remote.hxx"
#include "NETGENPlugin_DriverParam.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_ParallelMesh.hxx>
#include <SMESH_MesherHelper.hxx>
#include <SMESH_DriverShape.hxx>
#include <SMESH_DriverMesh.hxx>
#include <SMESHDS_Mesh.hxx>
#include <SMESH_MeshLocker.hxx>
#include <QString>
#include <QProcess>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
/*
Netgen include files
*/
#ifndef OCCGEOMETRY
#define OCCGEOMETRY
#endif
#include <occgeom.hpp>
#ifdef NETGEN_V5
#include <ngexception.hpp>
#endif
#ifdef NETGEN_V6
#include <core/exception.hpp>
#endif
namespace nglib {
#include <nglib.h>
}
namespace netgen {
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
NETGENPLUGIN_DLL_HEADER
extern volatile multithreadt multithread;
}
using namespace nglib;
//=============================================================================
/*!
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_Remote::NETGENPlugin_NETGEN_2D_Remote(int hypId, SMESH_Gen * gen)
: NETGENPlugin_NETGEN_2D_ONLY(hypId, gen)
{
_name = "NETGEN_2D_Remote";
}
//=============================================================================
/*!
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_Remote::~NETGENPlugin_NETGEN_2D_Remote()
{
}
/**
* @brief Fill the structure netgen_param with the information from the hypothesis
*
* @param hyp the hypothesis
* @param aParams the netgen_param structure
*/
void NETGENPlugin_NETGEN_2D_Remote::fillParameters(const NETGENPlugin_Hypothesis* hyp, netgen_params &aParams)
{
aParams.myType = hypoType::Hypo;
aParams.maxh = hyp->GetMaxSize();
aParams.minh = hyp->GetMinSize();
aParams.segmentsperedge = hyp->GetNbSegPerEdge();
aParams.grading = hyp->GetGrowthRate();
aParams.curvaturesafety = hyp->GetNbSegPerRadius();
aParams.secondorder = hyp->GetSecondOrder() ? 1 : 0;
aParams.quad = hyp->GetQuadAllowed() ? 1 : 0;
aParams.optimize = hyp->GetOptimize();
aParams.fineness = hyp->GetFineness();
aParams.uselocalh = hyp->GetSurfaceCurvature();
aParams.merge_solids = hyp->GetFuseEdges();
aParams.chordalError = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
aParams.optsteps2d = aParams.optimize ? hyp->GetNbSurfOptSteps() : 0;
aParams.optsteps3d = aParams.optimize ? hyp->GetNbVolOptSteps() : 0;
aParams.elsizeweight = hyp->GetElemSizeWeight();
aParams.opterrpow = hyp->GetWorstElemMeasure();
aParams.delaunay = hyp->GetUseDelauney();
aParams.checkoverlap = hyp->GetCheckOverlapping();
aParams.checkchartboundary = hyp->GetCheckChartBoundary();
#ifdef NETGEN_V6
// std::string
aParams.meshsizefilename = hyp->GetMeshSizeFile();
aParams.closeedgefac = 2;
aParams.nbThreads = hyp->GetNbThreads();
#else
// const char*
aParams.meshsizefilename = hyp->GetMeshSizeFile();
aParams.closeedgefac = 0;
aParams.nbThreads = 0;
#endif
}
/**
* @brief write in a binary file the orientation for each surface element of the mesh
*
* @param aMesh The mesh
* @param aShape the shape associated to the mesh
* @param output_file name of the binary file
*/
void NETGENPlugin_NETGEN_2D_Remote::exportElementOrientation(const std::string output_file)
{
std::ofstream df(output_file, ios::out|ios::binary);
int size=0;
df.write((char*)&size, sizeof(int));
df.close();
}
/**
* @brief Compute mesh associate to shape
*
* @param aMesh The mesh
* @param aShape The shape
* @return true fi there are some error
*/
bool NETGENPlugin_NETGEN_2D_Remote::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
{
SMESH_MeshLocker myLocker(&aMesh);
SMESH_Hypothesis::Hypothesis_Status hypStatus;
NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis(aMesh, aShape, hypStatus);
}
SMESH_ParallelMesh& aParMesh = dynamic_cast<SMESH_ParallelMesh&>(aMesh);
// Temporary folder for run
#ifdef WIN32
fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::path("Volume-%%%%-%%%%");
#else
fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::unique_path(fs::path("Volume-%%%%-%%%%"));
#endif
fs::create_directories(tmp_folder);
// Using MESH2D generated after all triangles where created.
fs::path mesh_file=aParMesh.GetTmpFolder() / fs::path("Mesh1D.med"); // read the premeshed elements from 2D version
fs::path element_orientation_file=tmp_folder / fs::path("element_orientation.dat");
fs::path new_element_file=tmp_folder / fs::path("new_elements.dat");
// Not used kept for debug
//fs::path output_mesh_file=tmp_folder / fs::path("output_mesh.med");
fs::path shape_file=tmp_folder / fs::path("shape.brep");
fs::path param_file=tmp_folder / fs::path("netgen_lenghtfromedge.txt"); /*becuase name contain 'lenghtfromedge' set length of 2D from premeshed 1D elements*/
fs::path log_file=tmp_folder / fs::path("run.log");
fs::path cmd_file=tmp_folder / fs::path("cmd.txt");
std::string mesh_name = "MESH";
{
SMESH_MeshLocker myLocker(&aMesh);
//Writing Shape
SMESH_DriverShape::exportShape(shape_file.string(), aShape);
//Writing hypo
// netgen_params aParams;
// fillParameters(_hypParameters, aParams);
// exportNetgenParams(param_file.string(), aParams);
{
// Simply write the file with the proper name
std::ofstream myfile(param_file.string());
myfile << 1 << std::endl;
myfile.close();
}
// Exporting element orientation
exportElementOrientation(element_orientation_file.string());
}
// Calling run_mesher
// Path to mesher script
fs::path mesher_launcher = fs::path(std::getenv("SMESH_ROOT_DIR"))/
fs::path("bin")/
fs::path("salome")/
fs::path("mesher_launcher.py");
std::string s_program="python3";
std::list<std::string> params;
params.push_back(mesher_launcher.string());
params.push_back("NETGEN2D");
params.push_back(mesh_file.string());
params.push_back(shape_file.string());
params.push_back(param_file.string());
params.push_back("--elem-orient-file=" + element_orientation_file.string());
params.push_back("--new-element-file=" + new_element_file.string());
// params.push_back("--output-mesh-file=" + output_mesh_file.string());
// Parallelism method parameters
int method = aParMesh.GetParallelismMethod();
if(method == ParallelismMethod::MultiThread){
params.push_back("--method=local");
} else if (method == ParallelismMethod::MultiNode){
params.push_back("--method=cluster");
params.push_back("--resource="+aParMesh.GetResource());
params.push_back("--wc-key="+aParMesh.GetWcKey());
params.push_back("--nb-proc=1");
params.push_back("--nb-proc-per-node="+to_string(aParMesh.GetNbProcPerNode()));
params.push_back("--nb-node="+to_string(aParMesh.GetNbNode()));
params.push_back("--walltime="+aParMesh.GetWalltime());
} else {
throw SALOME_Exception("Unknown parallelism method "+method);
}
std::string cmd = "";
cmd += s_program;
for(auto arg: params){
cmd += " " + arg;
}
MESSAGE("Running command: ");
MESSAGE(cmd);
// Writing command in cmd.log
{
std::ofstream flog(cmd_file.string());
flog << cmd << endl;
}
// Building arguments for QProcess
QString program = QString::fromStdString(s_program);
QStringList arguments;
for(auto arg : params){
arguments << arg.c_str();
}
QString out_file = log_file.string().c_str();
QProcess myProcess;
// myProcess.setProcessChannelMode(QProcess::MergedChannels);
myProcess.setProcessChannelMode(QProcess::ForwardedChannels);
myProcess.setStandardOutputFile(out_file);
myProcess.start(program, arguments);
// Waiting for process to finish (argument -1 make it wait until the end of
// the process otherwise it just waits 30 seconds)
bool finished = myProcess.waitForFinished(-1);
int ret = myProcess.exitCode();
if(ret != 0 || !finished){
// Run crahed
std::string msg = "Issue with mesh_launcher: \n";
msg += "See log for more details: " + log_file.string() + "\n";
msg += cmd + "\n";
throw SALOME_Exception(msg);
}
{
SMESH_MeshLocker myLocker(&aMesh);
std::ifstream df(new_element_file.string(), ios::binary);
int totalPremeshedNodes;
int NetgenNbOfNodes;
int NetgenNbOfNodesNew;
int NetgenNbOfTriangles;
double NetgenPoint[3];
int NetgenTriangle[3];
int nodeID;
SMESH_MesherHelper helper(aMesh);
// This function is mandatory for setElementsOnShape to work
helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
df.read((char*) &totalPremeshedNodes, sizeof(int));
// Number of nodes in intial mesh
df.read((char*) &NetgenNbOfNodes, sizeof(int));
// Number of nodes added by netgen
df.read((char*) &NetgenNbOfNodesNew, sizeof(int));
// Filling nodevec (correspondence netgen numbering mesh numbering)
vector< const SMDS_MeshNode* > nodeVec ( NetgenNbOfNodesNew + 2 );
SMESHDS_Mesh * meshDS = helper.GetMeshDS();
for (int nodeIndex = 1; nodeIndex <= NetgenNbOfNodes; ++nodeIndex )
{
//Id of the point
df.read((char*) &nodeID, sizeof(int));
nodeVec.at(nodeID) = meshDS->FindNode(nodeID);
}
// Add new points and update nodeVec
for (int nodeIndex = totalPremeshedNodes + 1; nodeIndex <= NetgenNbOfNodesNew; ++nodeIndex )
{
df.read((char *) &NetgenPoint, sizeof(double)*3);
nodeVec.at(nodeIndex) = helper.AddNode(NetgenPoint[0], NetgenPoint[1], NetgenPoint[2]);
}
// Add triangles
df.read((char*) &NetgenNbOfTriangles, sizeof(int));
for ( int elemIndex = 1; elemIndex <= NetgenNbOfTriangles; ++elemIndex )
{
df.read((char*) &NetgenTriangle, sizeof(int)*3);
if ( nodeVec.at( NetgenTriangle[0] ) && nodeVec.at( NetgenTriangle[1] ) && nodeVec.at( NetgenTriangle[2] ) )
helper.AddFace(nodeVec.at( NetgenTriangle[0] ), nodeVec.at( NetgenTriangle[1] ), nodeVec.at( NetgenTriangle[2] ) );
}
}
return true;
}
/**
* @brief Assign submeshes to compute
*
* @param aSubMesh submesh to add
*/
void NETGENPlugin_NETGEN_2D_Remote::setSubMeshesToCompute(SMESH_subMesh * aSubMesh)
{
SMESH_MeshLocker myLocker(aSubMesh->GetFather());
SMESH_Algo::setSubMeshesToCompute(aSubMesh);
}

View File

@ -0,0 +1,73 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//=============================================================================
// File : NETGENPlugin_NETGEN_2D_Remote.hxx
// Created : mardi 12 Decembre 2023
// Author : Cesar Conopoima (OCC)
// Project : SALOME
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_2D_REMOTE_HXX_
#define _NETGENPlugin_NETGEN_2D_REMOTE_HXX_
#include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
#include <vector>
#include <map>
class StdMeshers_ViscousLayers;
class StdMeshers_MaxElementVolume;
class NETGENPlugin_Hypothesis;
class NETGENPlugin_NetgenLibWrapper;
class netgen_params;
class SMDS_MeshNode;
using namespace std;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_2D_Remote: public NETGENPlugin_NETGEN_2D_ONLY
{
public:
NETGENPlugin_NETGEN_2D_Remote(int hypId, SMESH_Gen* gen);
virtual ~NETGENPlugin_NETGEN_2D_Remote();
// Function whould not be used with remote Computing
bool CheckHypothesis (SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
Hypothesis_Status& aStatus) override {(void)aMesh;(void)aShape;aStatus = HYP_OK;return true;};
bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape) override;
void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) override;
private:
void exportElementOrientation(const std::string output_file);
void fillParameters(const NETGENPlugin_Hypothesis* hyp,
netgen_params &aParams);
};
#endif

View File

@ -0,0 +1,77 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
// File : NETGENPlugin_NETGEN_2D_Remote_i.cxx
// Author : Cesar Conopoima (OCC)
// Module : NETGENPlugin
// $Header$
//
#include "NETGENPlugin_NETGEN_2D_Remote_i.hxx"
#include "SMESH_Gen.hxx"
#include "Utils_CorbaException.hxx"
#include "utilities.h"
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_Remote_i::NETGENPlugin_NETGEN_2D_Remote_i
*
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_Remote_i::NETGENPlugin_NETGEN_2D_Remote_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ),
SMESH_Algo_i( thePOA ),
SMESH_2D_Algo_i( thePOA )
{
myBaseImpl = new ::NETGENPlugin_NETGEN_2D_Remote( theGenImpl->GetANewId(), theGenImpl );
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_Remote_i::~NETGENPlugin_NETGEN_2D_Remote_i
*
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_Remote_i::~NETGENPlugin_NETGEN_2D_Remote_i()
{
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_2D_Remote_i::GetImpl
*
* Get implementation
*/
//=============================================================================
::NETGENPlugin_NETGEN_2D_Remote* NETGENPlugin_NETGEN_2D_Remote_i::GetImpl()
{
return ( ::NETGENPlugin_NETGEN_2D_Remote* )myBaseImpl;
}

View File

@ -0,0 +1,58 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
// File : NETGENPlugin_NETGEN_2D_Remote_i.hxx
// Author : Cesar Conopoima (OCC)
// Module : NETGENPlugin
// $Header$
//
#ifndef _NETGENPlugin_NETGEN_2D_REMOTE_I_HXX_
#define _NETGENPlugin_NETGEN_2D_REMOTE_I_HXX_
#include "NETGENPlugin_Defs.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
#include "SMESH_2D_Algo_i.hxx"
#include "NETGENPlugin_NETGEN_2D_Remote.hxx"
// ======================================================
// NETGEN 2d algorithm
// ======================================================
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_2D_Remote_i:
public virtual POA_NETGENPlugin::NETGENPlugin_NETGEN_2D_Remote,
public virtual SMESH_2D_Algo_i
{
public:
// Constructor
NETGENPlugin_NETGEN_2D_Remote_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl );
// Destructor
virtual ~NETGENPlugin_NETGEN_2D_Remote_i();
// Get implementation
::NETGENPlugin_NETGEN_2D_Remote* GetImpl();
};
#endif

View File

@ -0,0 +1,298 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// NETGENPlugin : C++ implementation
// File : NETGENPlugin_NETGEN_2D_SA.cxx
// Author : Cesar Conopoima (OCC)
// Date : 23/10/2023
// Project : SALOME
//=============================================================================
//
#include "NETGENPlugin_NETGEN_2D_SA.hxx"
#include "NETGENPlugin_Hypothesis_2D.hxx"
#include "NETGENPlugin_SimpleHypothesis_2D.hxx"
#include "NETGENPlugin_Mesher.hxx"
#include <SMESHDS_Mesh.hxx>
#include <SMESH_ControlsDef.hxx>
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_MesherHelper.hxx>
#include <SMESH_DriverShape.hxx>
#include <SMESH_DriverMesh.hxx>
#include <StdMeshers_LengthFromEdges.hxx>
#include <StdMeshers_MaxElementArea.hxx>
#include <utilities.h>
#ifdef WIN32
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#endif
namespace nglib {
#include <nglib.h>
}
#include <meshing.hpp>
using namespace nglib;
//=============================================================================
/*!
*
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_SA::NETGENPlugin_NETGEN_2D_SA()
: NETGENPlugin_NETGEN_2D_ONLY(0, new SMESH_Gen())
{
_name = "NETGEN_2D_SA";
}
//=============================================================================
/*!
*
*/
//=============================================================================
NETGENPlugin_NETGEN_2D_SA::~NETGENPlugin_NETGEN_2D_SA()
{
}
/**
* @brief Check presence and content of orientation file. Implemented for completness and future reference.
*
* @param element_orientation_file Binary file containing the orientation of surface elemnts
* @return true, false
*/
bool NETGENPlugin_NETGEN_2D_SA::checkOrientationFile( const std::string element_orientation_file )
{
if(element_orientation_file.empty()){
MESSAGE("No element orientation file");
return true;
} else {
MESSAGE("Reading from elements from file: " << element_orientation_file);
// By construction the orientation file written by Remote version has a zero written to mark no need of orientation in 2D meshing
int nbElement;
std::ifstream df(element_orientation_file, ios::binary|ios::in);
df.read((char*)&nbElement, sizeof(int));
df.close();
return (nbElement == 0);
}
}
/**
* @brief fill plugin hypothesis from the netgen_params structure
*
* @param aParams the structure
*/
void NETGENPlugin_NETGEN_2D_SA::fillHyp(const std::string param_file, netgen_params aParams)
{
if( aParams.has_netgen_param && aParams.myType == hypoType::Hypo )
{
NETGENPlugin_Hypothesis_2D * hyp = new NETGENPlugin_Hypothesis_2D(0, GetGen());
hyp->SetMaxSize(aParams.maxh);
hyp->SetMinSize(aParams.minh);
hyp->SetGrowthRate(aParams.grading);
hyp->SetQuadAllowed(aParams.quad);
hyp->SetFineness((NETGENPlugin_Hypothesis::Fineness)aParams.fineness);
hyp->SetChordalErrorEnabled(aParams.chordalError);
if(aParams.optimize){
hyp->SetNbSurfOptSteps(aParams.optsteps2d);
}
_hypParameters = dynamic_cast< const NETGENPlugin_Hypothesis_2D *> (hyp);
}
else
{
NETGENPlugin_Hypothesis * hyp = new NETGENPlugin_Hypothesis(0, GetGen());
if (param_file.find("lenghtfromedge") != std::string::npos )
{
_hypLengthFromEdges = dynamic_cast<const StdMeshers_LengthFromEdges*> (hyp);
}
else if ( param_file.find("maxarea") != std::string::npos )
{
StdMeshers_MaxElementArea * hyp = new StdMeshers_MaxElementArea(0, GetGen());
std::ifstream myfile(param_file);
std::string line;
double maxArea;
std::getline(myfile, line);
bool hashypothesis = std::stoi(line);
if ( hashypothesis )
{
std::getline(myfile, line);
maxArea = std::stod(line);
hyp->SetMaxArea( maxArea );
_hypMaxElementArea = static_cast<const StdMeshers_MaxElementArea*> (hyp);
}
myfile.close();
}
}
}
/**
* @brief Write a binary file containing information on the elements/nodes
* created by the mesher
*
* @param premeshedNodes map of the premeshed nodes of 1D elements
* @param newNetgenCoordinates map of the coordinate of new netgen points created in the mesh
* @param newNetgenElements map of the element triangulation
* @return true if there are some error
*/
bool NETGENPlugin_NETGEN_2D_SA::fillNewElementFile( std::string new_element_file,
const int numberOfGlobalPremeshedNodes,
std::map<int,const SMDS_MeshNode*>& premeshedNodes,
std::map<int,std::vector<double>>& newNetgenCoordinates,
std::map<int,std::vector<smIdType>>& newNetgenElements )
{
MESSAGE("Writting new elements")
int NetgenNbOfNodes = premeshedNodes.size();
int NetgenNbOfNodesNew = numberOfGlobalPremeshedNodes + newNetgenCoordinates.size();
int NetgenNbOfTriangles = newNetgenElements.size();
bool isOK = ( NetgenNbOfTriangles > 0 );
if ( isOK && !new_element_file.empty() )
{
int NetgenElement[3];
std::ofstream df(new_element_file, ios::out|ios::binary);
// Writing nodevec (correspondence netgen numbering mesh numbering)
// Number of nodes
df.write((char*) &numberOfGlobalPremeshedNodes, sizeof(int));
df.write((char*) &NetgenNbOfNodes, sizeof(int));
df.write((char*) &NetgenNbOfNodesNew, sizeof(int));
for (auto k : premeshedNodes )
df.write((char*) &k.first, sizeof(int));
// Writing info on new points
for (auto k : newNetgenCoordinates )
df.write((char*) k.second.data(), sizeof(double)*3 );
// create triangles
df.write((char*) &NetgenNbOfTriangles, sizeof(int));
for ( int elemIndex = 1; elemIndex <= NetgenNbOfTriangles; ++elemIndex )
{
int nodes = newNetgenElements[ elemIndex ].size();
for (int i = 0; i < nodes; i++)
NetgenElement[ i ] = (int) newNetgenElements[ elemIndex ][ i ];
df.write((char*) &NetgenElement, sizeof(int)* nodes );
}
df.close();
}
return false;
}
/**
* @brief Compute the mesh based on the
*
* @param input_mesh_file Mesh file (containing 2D elements)
* @param shape_file Shape file (BREP or STEP format)
* @param hypo_file Ascii file containing the netgen parameters
* @param element_orientation_file Binary file containing the orientation of surface elemnts
* @param new_element_file output file containing info the elements created by the mesher
* @param output_mesh_file output mesh file (if empty it will not be created)
* @return true, false
*/
bool NETGENPlugin_NETGEN_2D_SA::Compute( SMESH_Mesh& aMesh, TopoDS_Shape &aShape, std::string new_element_file )
{
// Nodes on edge are double because each face is treat one by one, so seam edges are iterated twice
vector< const SMDS_MeshNode* > nodeVec;
NETGENPlugin_Mesher aMesher( &aMesh, aShape, false /*isVolume=*/ );
NETGENPlugin_NetgenLibWrapper ngLib;
ngLib._isComputeOk = false;
fs::path netgen_log_file = fs::path(new_element_file).remove_filename() / fs::path("NETGEN.out");
MESSAGE("netgen ouput"<<netgen_log_file.string());
ngLib.setOutputFile(netgen_log_file.string());
netgen::OCCGeometry occgeoComm;
NETGENPlugin_NETGEN_2D_ONLY::SetParameteres( aMesh, aShape, aMesher, ngLib._ngMesh, occgeoComm, false /*submesh is not supported*/ );
std::map<int,const SMDS_MeshNode*> premeshedNodes;
std::map<int,std::vector<double>> newNetgenCoordinates;
std::map<int,std::vector<smIdType>> newNetgenElements;
const int numberOfTotalPremeshedNodes = aMesh.NbNodes();
bool compute = NETGENPlugin_NETGEN_2D_ONLY::MapSegmentsToEdges( aMesh, aShape, ngLib, nodeVec,
premeshedNodes, newNetgenCoordinates,
newNetgenElements );
compute = fillNewElementFile(new_element_file,
numberOfTotalPremeshedNodes,
premeshedNodes,
newNetgenCoordinates,
newNetgenElements);
return compute;
}
/**
* @brief Running the mesher on the given files
*
* @param input_mesh_file Mesh file (containing 2D elements)
* @param shape_file Shape file (BREP or STEP format)
* @param hypo_file Ascii file containing the netgen parameters
* @param element_orientation_file Binary file containing the orientation of surface elemnts
* @param new_element_file output file containing info the elements created by the mesher
* @param output_mesh_file output mesh file (if empty it will not be created)
* @return int
*/
int NETGENPlugin_NETGEN_2D_SA::run(const std::string input_mesh_file,
const std::string shape_file,
const std::string hypo_file,
const std::string element_orientation_file,
const std::string new_element_file,
const std::string output_mesh_file)
{
std::unique_ptr<SMESH_Mesh> myMesh(_gen->CreateMesh(false));
SMESH_DriverMesh::importMesh(input_mesh_file, *myMesh);
// Importing shape
TopoDS_Shape myShape;
SMESH_DriverShape::importShape(shape_file, myShape);
// Importing hypothesis
netgen_params myParams;
importNetgenParams(hypo_file, myParams);
fillHyp(hypo_file,myParams);
MESSAGE("Meshing with netgen2d");
int ret = 1;
if ( checkOrientationFile(element_orientation_file) )
{
ret = (int) Compute( *myMesh, myShape, new_element_file );
if(ret){
std::cerr << "Meshing failed" << std::endl;
return ret;
}
if(!output_mesh_file.empty()){
std::string meshName = "MESH";
SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
}
}
else
std::cerr << "For NETGENPlugin_NETGEN_2D_SA orientation file should be market with 0 or be empty!" << std::endl;
return ret;
}

View File

@ -0,0 +1,64 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// NETGENPlugin : C++ implementation
// File : NETGENPlugin_NETGEN_2D_SA.hxx
// Author : Cesar Conopoima (OCC)
// Date : 23/10/2023
// Project : SALOME
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_2D_SA_HXX_
#define _NETGENPlugin_NETGEN_2D_SA_HXX_
#include "NETGENPlugin_Defs.hxx"
#include "NETGENPlugin_DriverParam.hxx"
#include "NETGENPlugin_NETGEN_2D_ONLY.hxx"
#include "SMESH_Algo.hxx"
#include "SMESH_Mesh.hxx"
class NETGENPlugin_Mesher;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_2D_SA: public NETGENPlugin_NETGEN_2D_ONLY
{
public:
NETGENPlugin_NETGEN_2D_SA();
virtual ~NETGENPlugin_NETGEN_2D_SA();
bool Compute(SMESH_Mesh& aMesh, TopoDS_Shape &aShape, std::string new_element_file );
int run(const std::string input_mesh_file,
const std::string shape_file,
const std::string hypo_file,
const std::string element_orientation_file,
const std::string new_element_file,
const std::string output_mesh_file);
bool fillNewElementFile( std::string new_element_file,
const int numberOfGlobalPremeshedNodes,
std::map<int,const SMDS_MeshNode*>& premeshedNodes,
std::map<int,std::vector<double>>& newNetgenCoordinates,
std::map<int,std::vector<smIdType>>& newNetgenElements );
private:
bool checkOrientationFile( const std::string element_orientation_file );
void fillHyp(const std::string param_file, netgen_params aParams);
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -45,6 +45,8 @@
#include <StdMeshers_MaxElementVolume.hxx>
#include <StdMeshers_QuadToTriaAdaptor.hxx>
#include <StdMeshers_ViscousLayers.hxx>
#include <SMESH_subMesh.hxx>
#include <BRepGProp.hxx>
#include <BRep_Tool.hxx>
@ -63,6 +65,8 @@
#include <vector>
#include <map>
#include <cstdlib>
/*
Netgen include files
*/
@ -71,16 +75,18 @@
#define OCCGEOMETRY
#endif
#include <occgeom.hpp>
#ifdef NETGEN_V5
#include <ngexception.hpp>
#endif
#ifdef NETGEN_V6
#include <core/exception.hpp>
#endif
namespace nglib {
#include <nglib.h>
}
namespace netgen {
#ifdef NETGEN_V5
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
#else
extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
#endif
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
@ -141,8 +147,8 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh& aMesh,
_maxElementVolume = DBL_MAX;
// for correct work of GetProgress():
netgen::multithread.percent = 0.;
netgen::multithread.task = "Volume meshing";
//netgen::multithread.percent = 0.;
//netgen::multithread.task = "Volume meshing";
_progressByTic = -1.;
list<const SMESHDS_Hypothesis*>::const_iterator itl;
@ -184,71 +190,41 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh& aMesh,
return aStatus == HYP_OK;
}
//=============================================================================
/*!
*Here we are going to use the NETGEN mesher
*/
//=============================================================================
bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
netgen::multithread.terminate = 0;
netgen::multithread.task = "Volume meshing";
_progressByTic = -1.;
/**
* @brief Compute the list of already meshed Surface elements and info
* on their orientation and if they are internal
*
* @param aMesh Global Mesh
* @param aShape Shape associated to the mesh
* @param proxyMesh pointer to mesh used fo find the elements
* @param internals information on internal sub shapes
* @param helper helper associated to the mesh
* @param listElements map of surface element associated with
* their orientation and internal status
* @return true if their was some error
*/
bool NETGENPlugin_NETGEN_3D::getSurfaceElements(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_ProxyMesh::Ptr proxyMesh,
NETGENPlugin_Internals &internals,
SMESH_MesherHelper &helper,
std::map<const SMDS_MeshElement*, tuple<bool, bool>, TIDCompare>& listElements
)
{
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
SMESH_MesherHelper helper(aMesh);
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
int Netgen_NbOfNodes = 0;
double Netgen_point[3];
int Netgen_triangle[3];
NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
// vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec;
{
const int invalid_ID = -1;
SMESH::Controls::Area areaControl;
SMESH::Controls::TSequenceOfXYZ nodesCoords;
// maps nodes to ng ID
typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
typedef TNodeToIDMap::value_type TN2ID;
TNodeToIDMap nodeToNetgenID;
// find internal shapes
NETGENPlugin_Internals internals( aMesh, aShape, /*is3D=*/true );
// ---------------------------------
// Feed the Netgen with surface mesh
// ---------------------------------
TopAbs_ShapeEnum mainType = aMesh.GetShapeToMesh().ShapeType();
bool checkReverse = ( mainType == TopAbs_COMPOUND || mainType == TopAbs_COMPSOLID );
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
if ( _viscousLayersHyp )
{
netgen::multithread.percent = 3;
proxyMesh = _viscousLayersHyp->Compute( aMesh, aShape );
if ( !proxyMesh )
return false;
}
if ( aMesh.NbQuadrangles() > 0 )
{
netgen::multithread.percent = 6;
StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor;
Adaptor->Compute(aMesh,aShape,proxyMesh.get());
proxyMesh.reset( Adaptor );
}
for ( TopExp_Explorer exFa( aShape, TopAbs_FACE ); exFa.More(); exFa.Next())
{
const TopoDS_Shape& aShapeFace = exFa.Current();
@ -274,15 +250,107 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
iteratorElem = aSubMeshDSFace->GetElements();
}
while ( iteratorElem->more() ) // loop on elements on a geom face
{
// check mesh face
while(iteratorElem->more()){
const SMDS_MeshElement* elem = iteratorElem->next();
if ( !elem )
// check mesh face
if ( !elem ){
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
if ( elem->NbCornerNodes() != 3 )
}
if ( elem->NbCornerNodes() != 3 ){
return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
}
listElements[elem] = tuple<bool, bool>(isRev, isInternalFace);
}
}
return false;
}
/**
* @brief Part of Compute: adding already meshed elements
* into netgen structure
*
* @param aMesh Global mesh
* @param aShape Shape associated with the mesh
* @param nodeVec Mapping between nodes mesh id and netgen structure id
* @param ngLib Wrapper on netgen lib
* @param helper helper assocaited to the mesh
* @param Netgen_NbOfNodes Number of nodes in netge structure
* @return true if there was some error
*/
bool NETGENPlugin_NETGEN_3D::computeFillNgMesh(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
vector< const SMDS_MeshNode* > &nodeVec,
NETGENPlugin_NetgenLibWrapper &ngLib,
SMESH_MesherHelper &helper,
int &Netgen_NbOfNodes)
{
netgen::multithread.terminate = 0;
netgen::multithread.task = "Volume meshing";
_progressByTic = -1.;
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
_quadraticMesh = helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
Netgen_NbOfNodes = 0;
double Netgen_point[3];
int Netgen_triangle[3];
Ng_Mesh * Netgen_mesh = (Ng_Mesh*)ngLib._ngMesh;
{
const int invalid_ID = -1;
SMESH::Controls::Area areaControl;
SMESH::Controls::TSequenceOfXYZ nodesCoords;
// maps nodes to ng ID
// map must be sorted by ID to ensure that we will have the same number of
// 3D element if we recompute
typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
typedef TNodeToIDMap::value_type TN2ID;
TNodeToIDMap nodeToNetgenID;
// find internal shapes
NETGENPlugin_Internals internals( aMesh, aShape, /*is3D=*/true );
// ---------------------------------
// Feed the Netgen with surface mesh
// ---------------------------------
bool isRev=false;
bool isInternalFace=false;
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
if ( _viscousLayersHyp )
{
netgen::multithread.percent = 3;
proxyMesh = _viscousLayersHyp->Compute( aMesh, aShape );
if ( !proxyMesh )
return false;
}
if ( aMesh.NbQuadrangles() > 0 )
{
netgen::multithread.percent = 6;
StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor;
Adaptor->Compute(aMesh,aShape,proxyMesh.get());
proxyMesh.reset( Adaptor );
}
// map must be sorted by ID to ensure that we will have the same number of
// 3D element if we recompute
std::map<const SMDS_MeshElement*, tuple<bool, bool>, TIDCompare> listElements;
bool ret = getSurfaceElements(aMesh, aShape, proxyMesh, internals, helper, listElements);
if(ret)
return ret;
for ( auto const& [elem, info] : listElements ) // loop on elements on a geom face
{
isRev = get<0>(info);
isInternalFace = get<1>(info);
// Add nodes of triangles and triangles them-selves to netgen mesh
// add three nodes of triangle
@ -324,7 +392,6 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle);
}
} // loop on elements on a face
} // loop on faces of a SOLID or SHELL
// insert old nodes into nodeVec
nodeVec.resize( nodeToNetgenID.size() + 1, 0 );
@ -342,85 +409,236 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
internals);
}
}
// -------------------------
// Generate the volume mesh
// -------------------------
return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, Netgen_mesh));
Netgen_NbOfNodes = Ng_GetNP( Netgen_mesh );
return false;
}
// namespace
// {
// void limitVolumeSize( netgen::Mesh* ngMesh,
// double maxh )
// {
// // get average h of faces
// double faceh = 0;
// int nbh = 0;
// for (int i = 1; i <= ngMesh->GetNSE(); i++)
// {
// const netgen::Element2d& face = ngMesh->SurfaceElement(i);
// for (int j=1; j <= face.GetNP(); ++j)
// {
// const netgen::PointIndex & i1 = face.PNumMod(j);
// const netgen::PointIndex & i2 = face.PNumMod(j+1);
// if ( i1 < i2 )
// {
// const netgen::Point3d & p1 = ngMesh->Point( i1 );
// const netgen::Point3d & p2 = ngMesh->Point( i2 );
// faceh += netgen::Dist2( p1, p2 );
// nbh++;
// }
// }
// }
// faceh = Sqrt( faceh / nbh );
/**
* @brief Part of Compute: Setting the netgen parameters from the Hypothesis
*
* @param aMesh Global mesh
* @param ngLib Wrapper on netgen lib
* @param occgeo Mapping between nodes mesh id and netgen structure id
* @param helper helper assocaited to the mesh
* @param endWith end step of netgen
* @return true if there was some error
*/
bool NETGENPlugin_NETGEN_3D::computePrepareParam(
SMESH_Mesh& aMesh,
NETGENPlugin_NetgenLibWrapper &ngLib,
netgen::OCCGeometry &occgeo,
SMESH_MesherHelper &helper,
int &endWith)
// double compareh;
// if ( faceh < 0.5 * maxh ) compareh = -1;
// else if ( faceh > 1.5 * maxh ) compareh = 1;
// else compareh = 0;
// // cerr << "faceh " << faceh << endl;
// // cerr << "init maxh " << maxh << endl;
// // cerr << "compareh " << compareh << endl;
{
netgen::multithread.terminate = 0;
// if ( compareh > 0 )
// maxh *= 1.2;
// else
// maxh *= 0.8;
// // cerr << "maxh " << maxh << endl;
netgen::Mesh* ngMesh = ngLib._ngMesh;
// // get bnd box
// netgen::Point3d pmin, pmax;
// ngMesh->GetBox( pmin, pmax, 0 );
// const double dx = pmax.X() - pmin.X();
// const double dy = pmax.Y() - pmin.Y();
// const double dz = pmax.Z() - pmin.Z();
NETGENPlugin_Mesher aMesher( &aMesh, helper.GetSubShape(), /*isVolume=*/true );
// if ( ! & ngMesh->LocalHFunction() )
// ngMesh->SetLocalH( pmin, pmax, compareh <= 0 ? 0.1 : 0.5 );
if ( _hypParameters )
{
aMesher.SetParameters( _hypParameters );
// // adjusted by SALOME_TESTS/Grids/smesh/bugs_08/I8
// const int nbX = Max( 2, int( dx / maxh * 2 ));
// const int nbY = Max( 2, int( dy / maxh * 2 ));
// const int nbZ = Max( 2, int( dz / maxh * 2 ));
if ( !_hypParameters->GetLocalSizesAndEntries().empty() ||
!_hypParameters->GetMeshSizeFile().empty() )
{
if ( ! &ngMesh->LocalHFunction() )
{
netgen::Point3d pmin, pmax;
ngMesh->GetBox( pmin, pmax, 0 );
ngMesh->SetLocalH( pmin, pmax, _hypParameters->GetGrowthRate() );
}
aMesher.SetLocalSize( occgeo, *ngMesh );
// netgen::Point3d p;
// for ( int i = 0; i <= nbX; ++i )
// {
// p.X() = pmin.X() + i * dx / nbX;
// for ( int j = 0; j <= nbY; ++j )
// {
// p.Y() = pmin.Y() + j * dy / nbY;
// for ( int k = 0; k <= nbZ; ++k )
// {
// p.Z() = pmin.Z() + k * dz / nbZ;
// ngMesh->RestrictLocalH( p, maxh );
// }
// }
// }
// }
// }
try {
ngMesh->LoadLocalMeshSize( netgen::mparam.meshsizefilename );
} catch (netgen::NgException & ex) {
return error( COMPERR_BAD_PARMETERS, ex.What() );
}
}
if ( !_hypParameters->GetOptimize() )
endWith = netgen::MESHCONST_MESHVOLUME;
}
else if ( _hypMaxElementVolume )
{
netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
// limitVolumeSize( ngMesh, mparam.maxh ); // result is unpredictable
}
else if ( aMesh.HasShapeToMesh() )
{
aMesher.PrepareOCCgeometry( occgeo, helper.GetSubShape(), aMesh );
netgen::mparam.maxh = occgeo.GetBoundingBox().Diam()/2;
}
else
{
netgen::Point3d pmin, pmax;
ngMesh->GetBox (pmin, pmax);
netgen::mparam.maxh = Dist(pmin, pmax)/2;
}
if ( !_hypParameters && aMesh.HasShapeToMesh() )
{
netgen::mparam.minh = aMesher.GetDefaultMinSize( helper.GetSubShape(), netgen::mparam.maxh );
}
return false;
}
/**
* @brief Part of Compute: call to the netgen mesher
*
* @param occgeo netgen geometry structure
* @param nodeVec Mapping between nodes mesh id and netgen structure id
* @param ngMesh netgen mesh structure
* @param ngLib Wrapper on netgen lib
* @param startWith starting step of netgen
* @param endWith end step of netgen
* @return true if there was some error
*/
bool NETGENPlugin_NETGEN_3D::computeRunMesher(
netgen::OCCGeometry &occgeo,
vector< const SMDS_MeshNode* > &nodeVec,
netgen::Mesh* ngMesh,
NETGENPlugin_NetgenLibWrapper &ngLib,
int &startWith, int &endWith)
{
int err = 1;
try
{
OCC_CATCH_SIGNALS;
ngLib.CalcLocalH(ngMesh);
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
if(netgen::multithread.terminate)
return false;
if ( err ){
error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
}
}
catch (Standard_Failure& ex)
{
SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
str << " at " << netgen::multithread.task
<< ": " << ex.DynamicType()->Name();
if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
str << ": " << ex.GetMessageString();
error(str);
}
catch (netgen::NgException& exc)
{
SMESH_Comment str("NgException");
if ( strlen( netgen::multithread.task ) > 0 )
str << " at " << netgen::multithread.task;
str << ": " << exc.What();
error(str);
}
catch (...)
{
SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
if ( strlen( netgen::multithread.task ) > 0 )
str << " at " << netgen::multithread.task;
error(str);
}
if ( err )
{
SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::ReadErrors(nodeVec);
if ( ce && ce->HasBadElems() ){
error( ce );
}
}
return false;
}
/**
* @brief Part of Compute: Adding new element created by mesher to SMESH_Mesh
*
* @param nodeVec Mapping between nodes mesh id and netgen structure id
* @param ngLib Wrapper on netgen lib
* @param helper tool associated to the mesh to add element
* @param Netgen_NbOfNodes Number of nodes in netgen structure
* @return true if there was some error
*/
bool NETGENPlugin_NETGEN_3D::computeFillMesh(
vector< const SMDS_MeshNode* > &nodeVec,
NETGENPlugin_NetgenLibWrapper &ngLib,
SMESH_MesherHelper &helper,
int &Netgen_NbOfNodes
)
{
Ng_Mesh* Netgen_mesh = ngLib.ngMesh();
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
bool isOK = ( /*status == NG_OK &&*/ Netgen_NbOfTetra > 0 );// get whatever built
if ( isOK )
{
double Netgen_point[3];
int Netgen_tetrahedron[4];
// create and insert new nodes into nodeVec
nodeVec.resize( Netgen_NbOfNodesNew + 1, 0 );
int nodeIndex = Netgen_NbOfNodes + 1;
for ( ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex )
{
Ng_GetPoint( Netgen_mesh, nodeIndex, Netgen_point );
nodeVec.at(nodeIndex) = helper.AddNode(Netgen_point[0], Netgen_point[1], Netgen_point[2]);
}
// create tetrahedrons
for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
{
Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron);
try
{
helper.AddVolume (nodeVec.at( Netgen_tetrahedron[0] ),
nodeVec.at( Netgen_tetrahedron[1] ),
nodeVec.at( Netgen_tetrahedron[2] ),
nodeVec.at( Netgen_tetrahedron[3] ));
}
catch (...)
{
}
}
}
return false;
}
/**
* @brief Compute mesh associate to shape
*
* @param aMesh The mesh
* @param aShape The shape
* @return true fi there are some error
*/
bool NETGENPlugin_NETGEN_3D::Compute(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
// vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec;
NETGENPlugin_NetgenLibWrapper ngLib;
SMESH_MesherHelper helper(aMesh);
int startWith = netgen::MESHCONST_MESHVOLUME;
int endWith = netgen::MESHCONST_OPTVOLUME;
int Netgen_NbOfNodes;
computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, Netgen_NbOfNodes);
netgen::OCCGeometry occgeo;
computePrepareParam(aMesh, ngLib, occgeo, helper, endWith);
computeRunMesher(occgeo, nodeVec, ngLib._ngMesh, ngLib, startWith, endWith);
computeFillMesh(nodeVec, ngLib, helper, Netgen_NbOfNodes);
return false;
}
//================================================================================
/*!
@ -431,16 +649,14 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
SMESH_MesherHelper& helper,
vector< const SMDS_MeshNode* >& nodeVec,
Ng_Mesh * Netgen_mesh)
NETGENPlugin_NetgenLibWrapper& ngLib)
{
netgen::multithread.terminate = 0;
netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh;
netgen::Mesh* ngMesh = ngLib._ngMesh;
Ng_Mesh* Netgen_mesh = ngLib.ngMesh();
int Netgen_NbOfNodes = Ng_GetNP( Netgen_mesh );
#ifndef NETGEN_V5
char *optstr = 0;
#endif
int startWith = netgen::MESHCONST_MESHVOLUME;
int endWith = netgen::MESHCONST_OPTVOLUME;
int err = 1;
@ -475,7 +691,7 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
else if ( _hypMaxElementVolume )
{
netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
// limitVolumeSize( ngMesh, netgen::mparam.maxh ); // result is unpredictable
// limitVolumeSize( ngMesh, mparam.maxh ); // result is unpredictable
}
else if ( aMesh.HasShapeToMesh() )
{
@ -498,13 +714,9 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
{
OCC_CATCH_SIGNALS;
#ifdef NETGEN_V5
ngMesh->CalcLocalH(netgen::mparam.grading);
err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
#else
ngMesh->CalcLocalH();
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
ngLib.CalcLocalH(ngMesh);
err = ngLib.GenerateMesh(occgeo, startWith, endWith);
if(netgen::multithread.terminate)
return false;
if ( err )
@ -519,7 +731,7 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
str << ": " << ex.GetMessageString();
error(str);
}
catch (netgen::NgException exc)
catch (netgen::NgException& exc)
{
SMESH_Comment str("NgException");
if ( strlen( netgen::multithread.task ) > 0 )
@ -614,7 +826,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
int Netgen_triangle[3];
NETGENPlugin_NetgenLibWrapper ngLib;
Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
Ng_Mesh * Netgen_mesh = ngLib.ngMesh();
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
if ( aMesh.NbQuadrangles() > 0 )
@ -677,7 +889,7 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
// Generate the volume mesh
// -------------------------
return ( ngLib._isComputeOk = compute( aMesh, *aHelper, nodeVec, Netgen_mesh));
return ( ngLib._isComputeOk = compute( aMesh, *aHelper, nodeVec, ngLib ));
}
void NETGENPlugin_NETGEN_3D::CancelCompute()
@ -705,14 +917,12 @@ double NETGENPlugin_NETGEN_3D::GetProgress() const
strncmp( netgen::multithread.task, volMeshing, 3 ) == 0 ))
{
res = 0.001 + meshingRatio * netgen::multithread.percent / 100.;
//cout << netgen::multithread.task << " " <<_progressTic << "-" << netgen::multithread.percent << endl;
}
else // different otimizations
{
if ( _progressByTic < 0. )
((NETGENPlugin_NETGEN_3D*)this)->_progressByTic = meshingRatio / _progressTic;
res = _progressByTic * _progressTic;
//cout << netgen::multithread.task << " " << _progressTic << " " << res << endl;
}
return Min ( res, 0.98 );
}
@ -727,7 +937,7 @@ bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
{
int nbtri = 0, nbqua = 0;
smIdType nbtri = 0, nbqua = 0;
double fullArea = 0.0;
for (TopExp_Explorer expF(aShape, TopAbs_FACE); expF.More(); expF.Next()) {
TopoDS_Face F = TopoDS::Face( expF.Current() );
@ -738,9 +948,9 @@ bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
std::vector<smIdType> aVec = (*anIt).second;
nbtri += std::max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
nbqua += std::max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
GProp_GProps G;
BRepGProp::SurfaceProperties(F,G);
double anArea = G.Mass();
@ -748,7 +958,7 @@ bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
}
// collect info from edges
int nb0d_e = 0, nb1d_e = 0;
smIdType nb0d_e = 0, nb1d_e = 0;
bool IsQuadratic = false;
bool IsFirst = true;
TopTools_MapOfShape tmpMap;
@ -765,9 +975,9 @@ bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
"Submesh can not be evaluated",this));
return false;
}
std::vector<int> aVec = (*anIt).second;
std::vector<smIdType> aVec = (*anIt).second;
nb0d_e += aVec[SMDSEntity_Node];
nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
nb1d_e += std::max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
if(IsFirst) {
IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
IsFirst = false;
@ -775,7 +985,7 @@ bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
}
tmpMap.Clear();
double ELen_face = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
double ELen_face = sqrt(2.* ( fullArea/double(nbtri+nbqua*2) ) / sqrt(3.0) );
double ELen_vol = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
double ELen = Min(ELen_vol,ELen_face*2);
@ -784,11 +994,11 @@ bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
double aVolume = G.Mass();
double tetrVol = 0.1179*ELen*ELen*ELen;
double CoeffQuality = 0.9;
int nbVols = int( aVolume/tetrVol/CoeffQuality );
int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
int nb1d_in = (nbVols*6 - nb1d_e - nb1d_f ) / 5;
std::vector<int> aVec(SMDSEntity_Last);
for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
smIdType nbVols = (smIdType)( aVolume/tetrVol/CoeffQuality );
smIdType nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
smIdType nb1d_in = (nbVols*6 - nb1d_e - nb1d_f ) / 5;
std::vector<smIdType> aVec(SMDSEntity_Last);
for(smIdType i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
if( IsQuadratic ) {
aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -37,9 +37,15 @@
#include "SMESH_Algo.hxx"
#include "Utils_SALOME_Exception.hxx"
#include <vector>
#include <tuple>
class StdMeshers_ViscousLayers;
class StdMeshers_MaxElementVolume;
class NETGENPlugin_Hypothesis;
class NETGENPlugin_NetgenLibWrapper;
class netgen_params;
class SMDS_MeshNode;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
{
@ -65,12 +71,48 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap);
bool computeFillNgMesh(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
std::vector< const SMDS_MeshNode* > &nodeVec,
NETGENPlugin_NetgenLibWrapper &ngLib,
SMESH_MesherHelper &helper,
int &Netgen_NbOfNodes);
bool computePrepareParam(
SMESH_Mesh& aMesh,
NETGENPlugin_NetgenLibWrapper &ngLib,
netgen::OCCGeometry &occgeo,
SMESH_MesherHelper &helper,
int &endWith);
bool computeRunMesher(
netgen::OCCGeometry &occgeo,
std::vector< const SMDS_MeshNode* > &nodeVec,
netgen::Mesh* ngMesh,
NETGENPlugin_NetgenLibWrapper &ngLib,
int &startWith, int &endWith);
bool computeFillMesh(
std::vector< const SMDS_MeshNode* > &nodeVec,
NETGENPlugin_NetgenLibWrapper &ngLib,
SMESH_MesherHelper &helper,
int &Netgen_NbOfNodes);
protected:
virtual bool getSurfaceElements(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_ProxyMesh::Ptr proxyMesh,
NETGENPlugin_Internals &internals,
SMESH_MesherHelper &helper,
std::map<const SMDS_MeshElement*, std::tuple<bool, bool>, TIDCompare>& listElements);
bool compute(SMESH_Mesh& mesh,
SMESH_MesherHelper& helper,
std::vector< const SMDS_MeshNode* >& nodeVec,
nglib::Ng_Mesh* ngMesh);
NETGENPlugin_NetgenLibWrapper& ngLib);
double _maxElementVolume;

View File

@ -0,0 +1,406 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//=============================================================================
// File : NETGENPlugin_NETGEN_3D_Remote.cxx
// Created : lundi 19 Septembre 2022
// Author : Yoann AUDOUIN (CEA)
// Project : SALOME
//=============================================================================
//
//
#include "NETGENPlugin_NETGEN_3D_Remote.hxx"
#include "NETGENPlugin_NETGEN_3D.hxx"
#include "NETGENPlugin_DriverParam.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_ParallelMesh.hxx>
#include <SMESH_MesherHelper.hxx>
#include <SMESH_DriverShape.hxx>
#include <SMESH_DriverMesh.hxx>
#include <SMESHDS_Mesh.hxx>
#include <SMESH_MeshLocker.hxx>
#include <QString>
#include <QProcess>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
/*
Netgen include files
*/
#ifndef OCCGEOMETRY
#define OCCGEOMETRY
#endif
#include <occgeom.hpp>
#ifdef NETGEN_V5
#include <ngexception.hpp>
#endif
#ifdef NETGEN_V6
#include <core/exception.hpp>
#endif
namespace nglib {
#include <nglib.h>
}
namespace netgen {
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
NETGENPLUGIN_DLL_HEADER
extern volatile multithreadt multithread;
}
using namespace nglib;
//=============================================================================
/*!
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_Remote::NETGENPlugin_NETGEN_3D_Remote(int hypId, SMESH_Gen * gen)
: NETGENPlugin_NETGEN_3D(hypId, gen)
{
_name = "NETGEN_3D_Remote";
}
//=============================================================================
/*!
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_Remote::~NETGENPlugin_NETGEN_3D_Remote()
{
}
/**
* @brief Fill the structure netgen_param with the information from the hypothesis
*
* @param hyp the hypothesis
* @param aParams the netgen_param structure
*/
void NETGENPlugin_NETGEN_3D_Remote::fillParameters(const NETGENPlugin_Hypothesis* hyp, netgen_params &aParams)
{
aParams.myType = hypoType::Hypo;
aParams.maxh = hyp->GetMaxSize();
aParams.minh = hyp->GetMinSize();
aParams.segmentsperedge = hyp->GetNbSegPerEdge();
aParams.grading = hyp->GetGrowthRate();
aParams.curvaturesafety = hyp->GetNbSegPerRadius();
aParams.secondorder = hyp->GetSecondOrder() ? 1 : 0;
aParams.quad = hyp->GetQuadAllowed() ? 1 : 0;
aParams.optimize = hyp->GetOptimize();
aParams.fineness = hyp->GetFineness();
aParams.uselocalh = hyp->GetSurfaceCurvature();
aParams.merge_solids = hyp->GetFuseEdges();
aParams.chordalError = hyp->GetChordalErrorEnabled() ? hyp->GetChordalError() : -1.;
aParams.optsteps2d = aParams.optimize ? hyp->GetNbSurfOptSteps() : 0;
aParams.optsteps3d = aParams.optimize ? hyp->GetNbVolOptSteps() : 0;
aParams.elsizeweight = hyp->GetElemSizeWeight();
aParams.opterrpow = hyp->GetWorstElemMeasure();
aParams.delaunay = hyp->GetUseDelauney();
aParams.checkoverlap = hyp->GetCheckOverlapping();
aParams.checkchartboundary = hyp->GetCheckChartBoundary();
#ifdef NETGEN_V6
// std::string
aParams.meshsizefilename = hyp->GetMeshSizeFile();
aParams.closeedgefac = 2;
aParams.nbThreads = hyp->GetNbThreads();
#else
// const char*
aParams.meshsizefilename = hyp->GetMeshSizeFile();
aParams.closeedgefac = 0;
aParams.nbThreads = 0;
#endif
}
//
/**
* @brief write in a binary file the orientation for each surface element of the mesh
*
* @param aMesh The mesh
* @param aShape the shape associated to the mesh
* @param output_file name of the binary file
*/
void NETGENPlugin_NETGEN_3D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
const std::string output_file)
{
SMESH_MesherHelper helper(aMesh);
NETGENPlugin_Internals internals( aMesh, aShape, /*is3D=*/true );
SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
std::map<vtkIdType, bool> elemOrientation;
for ( TopExp_Explorer exFa( aShape, TopAbs_FACE ); exFa.More(); exFa.Next())
{
const TopoDS_Shape& aShapeFace = exFa.Current();
int faceID = aMesh.GetMeshDS()->ShapeToIndex( aShapeFace );
bool isInternalFace = internals.isInternalShape( faceID );
bool isRev = false;
if ( !isInternalFace &&
helper.NbAncestors(aShapeFace, aMesh, aShape.ShapeType()) > 1 )
// IsReversedSubMesh() can work wrong on strongly curved faces,
// so we use it as less as possible
isRev = helper.IsReversedSubMesh( TopoDS::Face( aShapeFace ));
const SMESHDS_SubMesh * aSubMeshDSFace = proxyMesh->GetSubMesh( aShapeFace );
if ( !aSubMeshDSFace ) continue;
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
if ( _quadraticMesh &&
dynamic_cast< const SMESH_ProxyMesh::SubMesh*>( aSubMeshDSFace ))
{
// add medium nodes of proxy triangles to helper (#16843)
while ( iteratorElem->more() )
helper.AddTLinks( static_cast< const SMDS_MeshFace* >( iteratorElem->next() ));
iteratorElem = aSubMeshDSFace->GetElements();
}
while ( iteratorElem->more() ) // loop on elements on a geom face
{
// check mesh face
const SMDS_MeshElement* elem = iteratorElem->next();
if ( !elem )
error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
if ( elem->NbCornerNodes() != 3 )
error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
elemOrientation[elem->GetID()] = isRev;
} // loop on elements on a face
} // loop on faces of a SOLID or SHELL
{
std::ofstream df(output_file, ios::out|ios::binary);
int size=elemOrientation.size();
df.write((char*)&size, sizeof(int));
for(auto const& [id, orient]:elemOrientation){
df.write((char*)&id, sizeof(vtkIdType));
df.write((char*)&orient, sizeof(bool));
}
}
}
/**
* @brief Compute mesh associate to shape
*
* @param aMesh The mesh
* @param aShape The shape
* @return true fi there are some error
*/
bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape)
{
{
SMESH_MeshLocker myLocker(&aMesh);
SMESH_Hypothesis::Hypothesis_Status hypStatus;
NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus);
}
SMESH_ParallelMesh& aParMesh = dynamic_cast<SMESH_ParallelMesh&>(aMesh);
// Temporary folder for run
#ifdef WIN32
fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::path("Volume-%%%%-%%%%");
#else
fs::path tmp_folder = aParMesh.GetTmpFolder() / fs::unique_path(fs::path("Volume-%%%%-%%%%"));
#endif
fs::create_directories(tmp_folder);
// Using MESH2D generated after all triangles where created.
fs::path mesh_file=aParMesh.GetTmpFolder() / fs::path("Mesh2D.med");
fs::path element_orientation_file=tmp_folder / fs::path("element_orientation.dat");
fs::path new_element_file=tmp_folder / fs::path("new_elements.dat");
fs::path tmp_mesh_file=tmp_folder / fs::path("tmp_mesh.med");
// Not used kept for debug
//fs::path output_mesh_file=tmp_folder / fs::path("output_mesh.med");
fs::path shape_file=tmp_folder / fs::path("shape.brep");
fs::path param_file=tmp_folder / fs::path("netgen3d_param.txt");
fs::path log_file=tmp_folder / fs::path("run.log");
fs::path cmd_file=tmp_folder / fs::path("cmd.txt");
// TODO: See if we can retreived name from aMesh ?
std::string mesh_name = "MESH";
{
SMESH_MeshLocker myLocker(&aMesh);
//Writing Shape
SMESH_DriverShape::exportShape(shape_file.string(), aShape);
//Writing hypo
netgen_params aParams;
fillParameters(_hypParameters, aParams);
exportNetgenParams(param_file.string(), aParams);
// Exporting element orientation
exportElementOrientation(aMesh, aShape, element_orientation_file.string());
}
// Calling run_mesher
// Path to mesher script
fs::path mesher_launcher = fs::path(std::getenv("SMESH_ROOT_DIR"))/
fs::path("bin")/
fs::path("salome")/
fs::path("mesher_launcher.py");
std::string s_program="python3";
std::list<std::string> params;
params.push_back(mesher_launcher.string());
params.push_back("NETGEN3D");
params.push_back(mesh_file.string());
params.push_back(shape_file.string());
params.push_back(param_file.string());
params.push_back("--elem-orient-file=" + element_orientation_file.string());
params.push_back("--new-element-file=" + new_element_file.string());
// Parallelism method parameters
int method = aParMesh.GetParallelismMethod();
if(method == ParallelismMethod::MultiThread){
params.push_back("--method=local");
} else if (method == ParallelismMethod::MultiNode){
params.push_back("--method=cluster");
params.push_back("--resource="+aParMesh.GetResource());
params.push_back("--wc-key="+aParMesh.GetWcKey());
params.push_back("--nb-proc=1");
params.push_back("--nb-proc-per-node="+to_string(aParMesh.GetNbProcPerNode()));
params.push_back("--nb-node="+to_string(aParMesh.GetNbNode()));
params.push_back("--walltime="+aParMesh.GetWalltime());
} else {
throw SALOME_Exception("Unknown parallelism method "+method);
}
std::string cmd = "";
cmd += s_program;
for(auto arg: params){
cmd += " " + arg;
}
MESSAGE("Running command: ");
MESSAGE(cmd);
// Writing command in cmd.log
{
std::ofstream flog(cmd_file.string());
flog << cmd << endl;
}
// Building arguments for QProcess
QString program = QString::fromStdString(s_program);
QStringList arguments;
for(auto arg : params){
arguments << arg.c_str();
}
QString out_file = log_file.string().c_str();
QProcess myProcess;
myProcess.setProcessChannelMode(QProcess::MergedChannels);
myProcess.setStandardOutputFile(out_file);
myProcess.start(program, arguments);
// Waiting for process to finish (argument -1 make it wait until the end of
// the process otherwise it just waits 30 seconds)
bool finished = myProcess.waitForFinished(-1);
int ret = myProcess.exitCode();
if(ret != 0 || !finished){
// Run crahed
std::string msg = "Issue with mesh_launcher: \n";
msg += "See log for more details: " + log_file.string() + "\n";
msg += cmd + "\n";
throw SALOME_Exception(msg);
}
{
SMESH_MeshLocker myLocker(&aMesh);
std::ifstream df(new_element_file.string(), ios::binary);
int Netgen_NbOfNodes;
int Netgen_NbOfNodesNew;
int Netgen_NbOfTetra;
double Netgen_point[3];
int Netgen_tetrahedron[4];
int nodeID;
SMESH_MesherHelper helper(aMesh);
// This function is mandatory for setElementsOnShape to work
helper.IsQuadraticSubMesh(aShape);
helper.SetElementsOnShape( true );
// Number of nodes in intial mesh
df.read((char*) &Netgen_NbOfNodes, sizeof(int));
// Number of nodes added by netgen
df.read((char*) &Netgen_NbOfNodesNew, sizeof(int));
// Filling nodevec (correspondence netgen numbering mesh numbering)
vector< const SMDS_MeshNode* > nodeVec ( Netgen_NbOfNodesNew + 1 );
//vector<int> nodeTmpVec ( Netgen_NbOfNodesNew + 1 );
SMESHDS_Mesh * meshDS = helper.GetMeshDS();
for (int nodeIndex = 1 ; nodeIndex <= Netgen_NbOfNodes; ++nodeIndex )
{
//Id of the point
df.read((char*) &nodeID, sizeof(int));
nodeVec.at(nodeIndex) = meshDS->FindNode(nodeID);
}
// Add new points and update nodeVec
for (int nodeIndex = Netgen_NbOfNodes +1 ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex )
{
df.read((char *) &Netgen_point, sizeof(double)*3);
nodeVec.at(nodeIndex) = helper.AddNode(Netgen_point[0],
Netgen_point[1],
Netgen_point[2]);
}
// Add tetrahedrons
df.read((char*) &Netgen_NbOfTetra, sizeof(int));
for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
{
df.read((char*) &Netgen_tetrahedron, sizeof(int)*4);
helper.AddVolume(
nodeVec.at( Netgen_tetrahedron[0] ),
nodeVec.at( Netgen_tetrahedron[1] ),
nodeVec.at( Netgen_tetrahedron[2] ),
nodeVec.at( Netgen_tetrahedron[3] ));
}
}
return true;
}
/**
* @brief Assign submeshes to compute
*
* @param aSubMesh submesh to add
*/
void NETGENPlugin_NETGEN_3D_Remote::setSubMeshesToCompute(SMESH_subMesh * aSubMesh)
{
SMESH_MeshLocker myLocker(aSubMesh->GetFather());
SMESH_Algo::setSubMeshesToCompute(aSubMesh);
}

View File

@ -0,0 +1,75 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//=============================================================================
// File : NETGENPlugin_NETGEN_3D_Remote.hxx
// Created : lundi 19 Septembre 2022
// Author : Yoann AUDOUIN (EDF)
// Project : SALOME
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_3D_REMOTE_HXX_
#define _NETGENPlugin_NETGEN_3D_REMOTE_HXX_
#include "NETGENPlugin_NETGEN_3D.hxx"
#include <vector>
#include <map>
class StdMeshers_ViscousLayers;
class StdMeshers_MaxElementVolume;
class NETGENPlugin_Hypothesis;
class NETGENPlugin_NetgenLibWrapper;
class netgen_params;
class SMDS_MeshNode;
using namespace std;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_Remote: public NETGENPlugin_NETGEN_3D
{
public:
NETGENPlugin_NETGEN_3D_Remote(int hypId, SMESH_Gen* gen);
virtual ~NETGENPlugin_NETGEN_3D_Remote();
// Function whould not be used with remote Computing
bool CheckHypothesis (SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
Hypothesis_Status& aStatus) override {(void)aMesh;(void)aShape;aStatus = HYP_OK;return true;};
bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape) override;
void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) override;
protected:
void exportElementOrientation(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
const std::string output_file);
void fillParameters(const NETGENPlugin_Hypothesis* hyp,
netgen_params &aParams);
};
#endif

View File

@ -0,0 +1,80 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
// File : NETGENPlugin_NETGEN_3D_Remote_i.cxx
// Author : Yoann AUDOUIN (EDF)
// Module : NETGENPlugin
// $Header$
//
#include "NETGENPlugin_NETGEN_3D_Remote_i.hxx"
#include "SMESH_Gen.hxx"
#include "Utils_CorbaException.hxx"
#include "utilities.h"
using namespace std;
//=============================================================================
/*!
* NETGENPlugin_NETGEN_3D_Remote_i::NETGENPlugin_NETGEN_3D_Remote_i
*
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_Remote_i::NETGENPlugin_NETGEN_3D_Remote_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl )
: SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA ),
SMESH_Algo_i( thePOA ),
SMESH_3D_Algo_i( thePOA )
{
myBaseImpl = new ::NETGENPlugin_NETGEN_3D_Remote( theGenImpl->GetANewId(),
theGenImpl );
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_3D_Remote_i::~NETGENPlugin_NETGEN_3D_Remote_i
*
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_Remote_i::~NETGENPlugin_NETGEN_3D_Remote_i()
{
}
//=============================================================================
/*!
* NETGENPlugin_NETGEN_3D_Remote_i::GetImpl
*
* Get implementation
*/
//=============================================================================
::NETGENPlugin_NETGEN_3D_Remote* NETGENPlugin_NETGEN_3D_Remote_i::GetImpl()
{
return ( ::NETGENPlugin_NETGEN_3D_Remote* )myBaseImpl;
}

View File

@ -0,0 +1,58 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
// File : NETGENPlugin_NETGEN_3D_Remote_i.hxx
// Author : Yoann AUDOUIN (EDF)
// Module : NETGENPlugin
// $Header$
//
#ifndef _NETGENPlugin_NETGEN_3D_REMOTE_I_HXX_
#define _NETGENPlugin_NETGEN_3D_REMOTE_I_HXX_
#include "NETGENPlugin_Defs.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm)
#include "SMESH_3D_Algo_i.hxx"
#include "NETGENPlugin_NETGEN_3D_Remote.hxx"
// ======================================================
// NETGEN 3d algorithm
// ======================================================
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_Remote_i:
public virtual POA_NETGENPlugin::NETGENPlugin_NETGEN_3D_Remote,
public virtual SMESH_3D_Algo_i
{
public:
// Constructor
NETGENPlugin_NETGEN_3D_Remote_i( PortableServer::POA_ptr thePOA,
::SMESH_Gen* theGenImpl );
// Destructor
virtual ~NETGENPlugin_NETGEN_3D_Remote_i();
// Get implementation
::NETGENPlugin_NETGEN_3D_Remote* GetImpl();
};
#endif

View File

@ -0,0 +1,400 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//=============================================================================
// File : NETGENPlugin_NETGEN_3D_SA.cxx
// Created : lundi 19 Septembre 2022
// Author : Yoann AUDOUIN (CEA)
// Project : SALOME
//=============================================================================
//
//
#include "NETGENPlugin_NETGEN_3D_SA.hxx"
#include "NETGENPlugin_DriverParam.hxx"
#include "NETGENPlugin_Hypothesis.hxx"
#include "StdMeshers_MaxElementVolume.hxx"
#include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx>
#include <SMESH_MesherHelper.hxx>
#include <SMESH_DriverShape.hxx>
#include <SMESH_DriverMesh.hxx>
#include <SMESHDS_Mesh.hxx>
#ifdef WIN32
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#endif
/*
Netgen include files
*/
#ifndef OCCGEOMETRY
#define OCCGEOMETRY
#endif
#include <occgeom.hpp>
#ifdef NETGEN_V5
#include <ngexception.hpp>
#endif
#ifdef NETGEN_V6
#include <core/exception.hpp>
#endif
namespace nglib {
#include <nglib.h>
}
namespace netgen {
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
NETGENPLUGIN_DLL_HEADER
extern volatile multithreadt multithread;
}
using namespace nglib;
//=============================================================================
/*!
* Constructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_SA::NETGENPlugin_NETGEN_3D_SA()
: NETGENPlugin_NETGEN_3D(0, new SMESH_Gen())
{
_name = "NETGEN_3D_SA";
}
//=============================================================================
/*!
* Destructor
*/
//=============================================================================
NETGENPlugin_NETGEN_3D_SA::~NETGENPlugin_NETGEN_3D_SA()
{
if(_gen)
delete _gen;
}
/**
* @brief fill plugin hypothesis from the netgen_params structure
*
* @param aParams the structure
* @param gen SMESH_Gen associate with the SA
*/
void NETGENPlugin_NETGEN_3D_SA::fillHyp(netgen_params aParams)
{
if(aParams.has_netgen_param){
NETGENPlugin_Hypothesis * hypParameters = new NETGENPlugin_Hypothesis(0, GetGen());
hypParameters->SetMaxSize(aParams.maxh);
hypParameters->SetMinSize(aParams.minh);
hypParameters->SetNbSegPerEdge(aParams.segmentsperedge);
hypParameters->SetGrowthRate(aParams.grading);
hypParameters->SetNbSegPerRadius(aParams.curvaturesafety);
hypParameters->SetSecondOrder(aParams.secondorder);
hypParameters->SetQuadAllowed(aParams.quad);
hypParameters->SetOptimize(aParams.optimize);
hypParameters->SetFineness((NETGENPlugin_Hypothesis::Fineness)aParams.fineness);
hypParameters->SetSurfaceCurvature(aParams.uselocalh);
hypParameters->SetFuseEdges(aParams.merge_solids);
hypParameters->SetChordalErrorEnabled(aParams.chordalError);
if(aParams.optimize){
hypParameters->SetNbSurfOptSteps(aParams.optsteps2d);
hypParameters->SetNbVolOptSteps(aParams.optsteps3d);
}
hypParameters->SetElemSizeWeight(aParams.elsizeweight);
hypParameters->SetWorstElemMeasure(aParams.opterrpow);
hypParameters->SetUseDelauney(aParams.delaunay);
hypParameters->SetCheckOverlapping(aParams.checkoverlap);
hypParameters->SetCheckChartBoundary(aParams.checkchartboundary);
hypParameters->SetMeshSizeFile(aParams.meshsizefilename);
_hypParameters = dynamic_cast< const NETGENPlugin_Hypothesis *> (hypParameters);
}
if(aParams.has_maxelementvolume_hyp){
_hypMaxElementVolume = new StdMeshers_MaxElementVolume(1, GetGen());
_maxElementVolume = aParams.maxElementVolume;
}
// TODO: Handle viscous layer
}
/**
* @brief Write a binary file containing information on the elements/nodes
* created by the mesher
*
* @param nodeVec mapping between the mesh id and the netgen structure id
* @param ngLib Wrapper on netgen library
* @param new_element_file Name of the output file
* @param Netgen_NbOfNodes Number of nodes in the netgen structure
* @return true if there are some error
*/
bool NETGENPlugin_NETGEN_3D_SA::computeFillNewElementFile(
std::vector< const SMDS_MeshNode* > &nodeVec,
NETGENPlugin_NetgenLibWrapper &ngLib,
std::string new_element_file,
int &Netgen_NbOfNodes
)
{
MESSAGE("Writting new elements")
Ng_Mesh* Netgen_mesh = ngLib.ngMesh();
int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
bool isOK = ( Netgen_NbOfTetra > 0 );
if ( isOK && !new_element_file.empty() )
{
std::ofstream df(new_element_file, ios::out|ios::binary);
double Netgen_point[3];
int Netgen_tetrahedron[4];
// Writing nodevec (correspondence netgen numbering mesh numbering)
// Number of nodes
df.write((char*) &Netgen_NbOfNodes, sizeof(int));
df.write((char*) &Netgen_NbOfNodesNew, sizeof(int));
for (int nodeIndex = 1 ; nodeIndex <= Netgen_NbOfNodes; ++nodeIndex )
{
//Id of the point
int id = nodeVec.at(nodeIndex)->GetID();
df.write((char*) &id, sizeof(int));
}
// Writing info on new points
for (int nodeIndex = Netgen_NbOfNodes +1 ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex )
{
Ng_GetPoint(Netgen_mesh, nodeIndex, Netgen_point );
// Coordinates of the point
df.write((char *) &Netgen_point, sizeof(double)*3);
}
// create tetrahedrons
df.write((char*) &Netgen_NbOfTetra, sizeof(int));
for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
{
Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron);
df.write((char*) &Netgen_tetrahedron, sizeof(int)*4);
}
}
return false;
}
/**
* @brief Compute mesh associated to shape
*
* @param aShape the shape
* @param aMesh the mesh
* @param aParams netgen_params structure
* @param new_element_file Name of the file containing new element
* @param output_mesh Name of the output mesh (if empty it will not be written)
* @return true if there are some error
*/
bool NETGENPlugin_NETGEN_3D_SA::Compute(
TopoDS_Shape &aShape,
SMESH_Mesh& aMesh,
netgen_params& aParams,
std::string new_element_file,
bool output_mesh)
{
MESSAGE("Compute");
// vector of nodes in which node index == netgen ID
vector< const SMDS_MeshNode* > nodeVec;
NETGENPlugin_NetgenLibWrapper ngLib;
SMESH_MesherHelper helper(aMesh);
int startWith = netgen::MESHCONST_MESHVOLUME;
int endWith = netgen::MESHCONST_OPTVOLUME;
int Netgen_NbOfNodes=0;
// Changing netgen log_file putting it next to new_element_file
fs::path netgen_log_file = fs::path(new_element_file).remove_filename() / fs::path("NETGEN.out");
MESSAGE("netgen ouput"<<netgen_log_file.string());
ngLib.setOutputFile(netgen_log_file.string());
NETGENPlugin_NETGEN_3D::computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, Netgen_NbOfNodes);
netgen::OCCGeometry occgeo;
NETGENPlugin_NETGEN_3D::computePrepareParam(aMesh, ngLib, occgeo, helper, endWith);
NETGENPlugin_NETGEN_3D::computeRunMesher(occgeo, nodeVec, ngLib._ngMesh, ngLib, startWith, endWith);
computeFillNewElementFile(nodeVec, ngLib, new_element_file, Netgen_NbOfNodes);
if(output_mesh)
NETGENPlugin_NETGEN_3D::computeFillMesh(nodeVec, ngLib, helper, Netgen_NbOfNodes);
return false;
}
/**
* @brief Running the mesher on the given files
*
* @param input_mesh_file Mesh file (containing 2D elements)
* @param shape_file Shape file (BREP or STEP format)
* @param hypo_file Ascii file containing the netgen parameters
* @param element_orientation_file Binary file containing the orientation of surface elemnts
* @param new_element_file output file containing info the elements created by the mesher
* @param output_mesh_file output mesh file (if empty it will not be created)
* @return int
*/
int NETGENPlugin_NETGEN_3D_SA::run(const std::string input_mesh_file,
const std::string shape_file,
const std::string hypo_file,
const std::string element_orientation_file,
const std::string new_element_file,
const std::string output_mesh_file)
{
_element_orientation_file = element_orientation_file;
std::unique_ptr<SMESH_Mesh> myMesh(_gen->CreateMesh(false));
SMESH_DriverMesh::importMesh(input_mesh_file, *myMesh);
// Importing shape
TopoDS_Shape myShape;
SMESH_DriverShape::importShape(shape_file, myShape);
// Importing hypothesis
netgen_params myParams;
importNetgenParams(hypo_file, myParams);
fillHyp(myParams);
MESSAGE("Meshing with netgen3d");
int ret = Compute(myShape, *myMesh, myParams,
new_element_file,
!output_mesh_file.empty());
if(ret){
std::cerr << "Meshing failed" << std::endl;
return ret;
}
if(!output_mesh_file.empty()){
std::string meshName = "MESH";
SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
}
return ret;
}
/**
* @brief Compute the list of already meshed Surface elements and info
* on their orientation and if they are internal
*
* @param aMesh Global Mesh
* @param aShape Shape associated to the mesh
* @param proxyMesh pointer to mesh used fo find the elements
* @param internals information on internal sub shapes
* @param helper helper associated to the mesh
* @param listElements map of surface element associated with
* their orientation and internal status
* @return true if their was some error
*/
bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_ProxyMesh::Ptr proxyMesh,
NETGENPlugin_Internals &internals,
SMESH_MesherHelper &helper,
std::map<const SMDS_MeshElement*, tuple<bool, bool>, TIDCompare>& listElements
)
{
// To remove compilation warnings
(void) aShape;
(void) proxyMesh;
(void) internals;
(void) helper;
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
// Get list of elements + their orientation from element_orientation file
std::map<vtkIdType, bool> elemOrientation;
{
// Setting all element orientation to false if there no element orientation file
if(_element_orientation_file.empty()){
MESSAGE("No element orientation file");
SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face);
while ( iteratorElem->more() ) // loop on elements on a geom face
{
// check mesh face
const SMDS_MeshElement* elem = iteratorElem->next();
elemOrientation[elem->GetID()] = false;
}
} else {
MESSAGE("Reading from elements from file: " << _element_orientation_file);
std::ifstream df(_element_orientation_file, ios::binary|ios::in);
int nbElement;
bool orient;
// Warning of the use of vtkIdType (I had issue when run_mesher was compiled with internal vtk) and salome not
// Sizeof was the same but how he othered the type was different
// Maybe using another type (uint64_t) instead would be better
vtkIdType id;
df.read((char*)&nbElement, sizeof(int));
for(int ielem=0;ielem<nbElement;++ielem){
df.read((char*) &id, sizeof(vtkIdType));
df.read((char*) &orient, sizeof(bool));
elemOrientation[id] = orient;
}
}
}
// Adding elements from Mesh
SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face);
bool isRev;
bool isIn;
while ( iteratorElem->more() ) // loop on elements on a geom face
{
// check mesh face
const SMDS_MeshElement* elem = iteratorElem->next();
if ( !elem ){
return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
}
if ( elem->NbCornerNodes() != 3 ){
return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
}
// Keeping only element that are in the element orientation file
isIn = elemOrientation.count(elem->GetID())==1;
if(!isIn)
continue;
// Get orientation
// Netgen requires that all the triangle point outside
isRev = elemOrientation[elem->GetID()];
listElements[elem] = tuple<bool, bool>(isRev, false);
}
return false;
}

View File

@ -0,0 +1,81 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//=============================================================================
// File : NETGENPlugin_NETGEN_3D_SA.hxx
// Created : lundi 19 Septembre 2022
// Author : Yoann AUDOUIN (EDF)
// Project : SALOME
//=============================================================================
//
#ifndef _NETGENPlugin_NETGEN_3D_SA_HXX_
#define _NETGENPlugin_NETGEN_3D_SA_HXX_
#include "NETGENPlugin_NETGEN_3D.hxx"
#include <vector>
#include <map>
class NETGENPlugin_NetgenLibWrapper;
class netgen_params;
class SMDS_MeshNode;
using namespace std;
class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_3D
{
public:
NETGENPlugin_NETGEN_3D_SA();
virtual ~NETGENPlugin_NETGEN_3D_SA();
void fillHyp(netgen_params aParams);
bool Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
std::string new_element_file, bool output_mesh);
int run(const std::string input_mesh_file,
const std::string shape_file,
const std::string hypo_file,
const std::string element_orientation_file,
const std::string new_element_file,
const std::string output_mesh_file);
protected:
bool computeFillNewElementFile(
std::vector< const SMDS_MeshNode* > &nodeVec,
NETGENPlugin_NetgenLibWrapper &ngLib,
std::string new_element_file,
int &Netgen_NbOfNodes);
bool getSurfaceElements(
SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
SMESH_ProxyMesh::Ptr proxyMesh,
NETGENPlugin_Internals &internals,
SMESH_MesherHelper &helper,
std::map<const SMDS_MeshElement*, tuple<bool, bool>, TIDCompare>& listElements
) override;
std::string _element_orientation_file="";
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -54,6 +54,9 @@ using namespace nglib;
namespace netgen {
NETGENPLUGIN_DLL_HEADER
extern MeshingParameters mparam;
NETGENPLUGIN_DLL_HEADER
extern STLParameters stlparam;
@ -63,7 +66,11 @@ namespace netgen {
namespace nglib
{
NETGENPLUGIN_DLL_HEADER
#ifdef NETGEN_V6
extern netgen::NgArray<netgen::Point<3> > readedges;
#else
extern netgen::Array<netgen::Point<3> > readedges;
#endif
}
namespace
@ -138,7 +145,7 @@ namespace
{
// define tolerance
double tol, len, sumLen = 0, minLen = 1e100;
int nbSeg = 0;
size_t nbSeg = 0;
for ( size_t i = 0; i < holes.size(); ++i )
{
nbSeg += holes[i].size();
@ -152,7 +159,7 @@ namespace
p1 = p2;
}
}
double avgLen = sumLen / nbSeg;
double avgLen = sumLen / double( nbSeg );
if ( minLen > 1e-5 * avgLen )
tol = 0.1 * minLen; // minLen is not degenerate
else
@ -209,8 +216,8 @@ namespace
gp_XYZ normal;
if ( SMESH_MeshAlgos::FaceNormal( f, normal ))
{
TIDSortedElemSet allFaces;
editor.Reorient2D( allFaces, normal, f );
TIDSortedElemSet allFaces, refFaces = { f };
editor.Reorient2D( allFaces, normal, refFaces, /*allowNonManifold=*/true );
break;
}
}
@ -649,8 +656,10 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
netgen::stlparam.resthchartdistenable = hyp->GetRestHChartDistEnable();
netgen::stlparam.resthlinelengthfac = hyp->GetRestHLineLengthFactor();
netgen::stlparam.resthlinelengthenable = hyp->GetRestHLineLengthEnable();
#ifndef NETGEN_V6
netgen::stlparam.resthcloseedgefac = hyp->GetRestHCloseEdgeFactor();
netgen::stlparam.resthcloseedgeenable = hyp->GetRestHCloseEdgeEnable();
#endif
netgen::stlparam.resthsurfcurvfac = hyp->GetRestHSurfCurvFactor();
netgen::stlparam.resthsurfcurvenable = hyp->GetRestHSurfCurvEnable();
netgen::stlparam.resthedgeanglefac = hyp->GetRestHEdgeAngleFactor();
@ -675,6 +684,15 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
netgen::STLGeometry* stlGeom = (netgen::STLGeometry*)ngStlGeo;
// the following code is taken from STLMeshing() method
#ifdef NETGEN_V6
stlGeom->Clear();
stlGeom->BuildEdges( netgen::stlparam );
stlGeom->MakeAtlas( *ngMesh, netgen::mparam, netgen::stlparam );
stlGeom->CalcFaceNums();
stlGeom->AddFaceEdges();
fixNodes( fixedEdges->GetGroupDS(), stlGeom );
stlGeom->LinkEdges( netgen::stlparam );
#else
stlGeom->Clear();
stlGeom->BuildEdges();
stlGeom->MakeAtlas( *ngMesh );
@ -682,7 +700,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
stlGeom->AddFaceEdges();
fixNodes( fixedEdges->GetGroupDS(), stlGeom );
stlGeom->LinkEdges();
#endif
ngMesh->ClearFaceDescriptors();
for (int i = 1; i <= stlGeom->GetNOFaces(); i++)
ngMesh->AddFaceDescriptor (netgen::FaceDescriptor (i, 1, 0, 0));
@ -691,7 +709,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
}
else
{
Ng_STL_MakeEdges( ngStlGeo, ngLib._ngMesh, &ngParams );
Ng_STL_MakeEdges( ngStlGeo, ngLib.ngMesh(), &ngParams );
}
netgen::mparam = savedParams;
@ -707,13 +725,10 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
netgen::OCCGeometry occgeo;
mesher.SetLocalSize( occgeo, *ngMesh );
// const char* optStr = "SmSmSm";//"smsmsmSmSmSm";
// netgen::mparam.optimize2d = optStr;
// meshing
try
{
ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib._ngMesh, &ngParams );
ng_res = Ng_STL_GenerateSurfaceMesh( ngStlGeo, ngLib.ngMesh(), &ngParams );
}
catch (netgen::NgException & ex)
{
@ -769,7 +784,7 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
// find existing groups
const char* theNamePrefix = "Surface_";
const int theNamePrefixLen = strlen( theNamePrefix );
const size_t theNamePrefixLen = strlen( theNamePrefix );
std::vector< SMESHDS_Group* > groups;
if ( hyp && hyp->GetMakeGroupsOfSurfaces() )
{
@ -852,8 +867,8 @@ bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
*/
//=============================================================================
bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& theMesh,
const TopoDS_Shape& theShape)
bool NETGENPlugin_Remesher_2D::Compute(SMESH_Mesh& /*theMesh*/,
const TopoDS_Shape& /*theShape*/)
{
return false;
}
@ -887,9 +902,9 @@ double NETGENPlugin_Remesher_2D::GetProgress() const
*/
//=============================================================================
bool NETGENPlugin_Remesher_2D::Evaluate(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
MapShapeNbElems& aResMap)
bool NETGENPlugin_Remesher_2D::Evaluate(SMESH_Mesh& /*aMesh*/,
const TopoDS_Shape& /*aShape*/,
MapShapeNbElems& /*aResMap*/)
{
return false;
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS

View File

@ -0,0 +1,125 @@
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : NETGENplugin_Runnner_main.cxx
// Author : Yoann AUDOUIN, EDF
// Module : NETGEN
//
#include "NETGENPlugin_NETGEN_2D_SA.hxx"
#include "NETGENPlugin_NETGEN_3D_SA.hxx"
#include "NETGENPlugin_NETGEN_1D2D3D_SA.hxx"
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <chrono>
/**
* @brief Main function
*
* @param argc Number of arguments
* @param argv Arguments
*
* @return error code
*/
int main(int argc, char *argv[]){
if(argc!=8||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
std::cout << "Error in number of arguments "<< argc-1<<" given expected 7" <<std::endl;
std::cout << "Syntax:"<<std::endl;
std::cout << "run_mesher MESHER INPUT_MESH_FILE SHAPE_FILE HYPO_FILE" << std::endl;
std::cout << " ELEM_ORIENT_FILE " << std::endl;
std::cout << " NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
std::cout << std::endl;
std::cout << " Set argument to NONE to ignore them " << std::endl;
std::cout << std::endl;
std::cout << "Args:" << std::endl;
std::cout << " MESHER: mesher to use from (NETGEN3D, NETGEN2D)" << std::endl;
std::cout << " INPUT_MESH_FILE: MED File containing lower-dimension-elements already meshed" << std::endl;
std::cout << " SHAPE_FILE: STEP file containing the shape to mesh" << std::endl;
std::cout << " HYPO_FILE: Ascii file containint the list of parameters" << std::endl;
std::cout << " (optional) ELEM_ORIENT_FILE: binary file containing the list of element from INPUT_MESH_FILE associated to the shape and their orientation" << std::endl;
std::cout << " (optional) NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << std::endl;
std::cout << " (optional) OUTPUT_MESH_FILE: (out) MED File containing the mesh after the run of the mesher" << std::endl;
return 1;
}
std::string mesher=argv[1];
std::string input_mesh_file=argv[2];
std::string shape_file=argv[3];
std::string hypo_file=argv[4];
std::string element_orientation_file=argv[5];
std::string new_element_file=argv[6];
std::string output_mesh_file=argv[7];
//std::string thing;
//std::cin >> thing;
if (output_mesh_file == "NONE")
output_mesh_file = "";
if (element_orientation_file == "NONE")
element_orientation_file = "";
if (new_element_file == "NONE")
new_element_file = "";
int ret = 0;
if (mesher=="NETGEN3D"){
NETGENPlugin_NETGEN_3D_SA myplugin;
ret = myplugin.run(input_mesh_file,
shape_file,
hypo_file,
element_orientation_file,
new_element_file,
output_mesh_file );
}
else if ( mesher=="NETGEN1D" ||
mesher=="NETGEN1D2D" ||
mesher=="NETGEN1D2D3D" )
{
NETGENPlugin_NETGEN_1D2D3D_SA myplugin;
NETGENPlugin_Mesher::DIM DIM = mesher=="NETGEN1D" ? NETGENPlugin_Mesher::D1
: ( mesher=="NETGEN1D2D" ? NETGENPlugin_Mesher::D2
: NETGENPlugin_Mesher::D3 );
ret = myplugin.run(input_mesh_file,
shape_file,
hypo_file,
element_orientation_file,
new_element_file,
output_mesh_file,
DIM );
}
else if ( mesher=="NETGEN2D" )
{
NETGENPlugin_NETGEN_2D_SA myplugin;
ret = myplugin.run(input_mesh_file,
shape_file,
hypo_file,
element_orientation_file,
new_element_file,
output_mesh_file );
}
else {
std::cerr << "Unknown mesher:" << mesher << std::endl;
return 1;
}
return ret;
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -59,9 +59,9 @@ NETGENPlugin_SimpleHypothesis_2D::NETGENPlugin_SimpleHypothesis_2D (int
*
*/
//=============================================================================
void NETGENPlugin_SimpleHypothesis_2D::SetNumberOfSegments(int nb) throw (SALOME_Exception)
void NETGENPlugin_SimpleHypothesis_2D::SetNumberOfSegments(int nb)
{
if ( nb < 1 )
if ( nb < 0 )
throw SALOME_Exception("Number of segments must be positive");
if (nb != _nbSegments)
{
@ -77,7 +77,6 @@ void NETGENPlugin_SimpleHypothesis_2D::SetNumberOfSegments(int nb) throw (SALOME
*/
//=============================================================================
void NETGENPlugin_SimpleHypothesis_2D::SetLocalLength(double segmentLength)
throw (SALOME_Exception)
{
if ( segmentLength < DBL_MIN )
throw SALOME_Exception("segment length must be more than zero");
@ -200,7 +199,7 @@ bool NETGENPlugin_SimpleHypothesis_2D::SetParametersByMesh(const SMESH_Mesh* t
const TopoDS_Shape& theShape)
{
// Find out nb of segments.
int nbSeg = 0, nbEdges = 0;
smIdType nbSeg = 0, nbEdges = 0;
TopExp_Explorer exp( theShape, TopAbs_EDGE );
for ( ; exp.More(); exp.Next() ) {
SMESH_subMesh* sm = theMesh->GetSubMeshContaining( exp.Current() );

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -29,7 +29,7 @@
#include "NETGENPlugin_Defs.hxx"
#include "SMESH_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "smIdType.hxx"
// Simplified parameters of NETGEN
//
@ -43,17 +43,17 @@ public:
/*!
* Sets <number of segments> value
*/
void SetNumberOfSegments(int nb) throw (SALOME_Exception);
void SetNumberOfSegments(int nb);
/*!
* Returns <number of segments> value.
* Can be zero in case if LocalLength() has been set
*/
int GetNumberOfSegments() const { return _nbSegments; }
smIdType GetNumberOfSegments() const { return _nbSegments; }
/*!
* Sets <segment length> value
*/
void SetLocalLength(double segmentLength) throw (SALOME_Exception);
void SetLocalLength(double segmentLength);
/*!
* Returns <segment length> value.
* Can be zero in case if NumberOfSegments() has been set
@ -104,7 +104,7 @@ public:
virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
private:
int _nbSegments;
smIdType _nbSegments;
double _segmentLength, _area;
bool _allowQuad;
};

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -71,8 +71,7 @@ NETGENPlugin_SimpleHypothesis_2D_i::~NETGENPlugin_SimpleHypothesis_2D_i()
* NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments
*/
//=============================================================================
void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb)
throw ( SALOME::SALOME_Exception )
void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Long nb)
{
ASSERT(myBaseImpl);
try {
@ -89,10 +88,10 @@ void NETGENPlugin_SimpleHypothesis_2D_i::SetNumberOfSegments(CORBA::Short nb)
* NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
*/
//=============================================================================
CORBA::Short NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
CORBA::Long NETGENPlugin_SimpleHypothesis_2D_i::GetNumberOfSegments()
{
ASSERT(myBaseImpl);
return this->GetImpl()->GetNumberOfSegments();
return (CORBA::Long) this->GetImpl()->GetNumberOfSegments();
}
//================================================================================
@ -237,7 +236,7 @@ int NETGENPlugin_SimpleHypothesis_2D_i::getParamIndex(const TCollection_AsciiStr
//================================================================================
std::string NETGENPlugin_SimpleHypothesis_2D_i::getMethodOfParameter(const int paramIndex,
int nbVars) const
int /*nbVars*/) const
{
switch ( paramIndex ) {
case 0: return GetImpl()->GetNumberOfSegments() ? "SetNumberOfSegments" : "SetLocalLength";

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -49,8 +49,8 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D_i:
// Destructor
virtual ~NETGENPlugin_SimpleHypothesis_2D_i();
void SetNumberOfSegments(CORBA::Short nb) throw ( SALOME::SALOME_Exception );
CORBA::Short GetNumberOfSegments();
void SetNumberOfSegments(CORBA::Long nb);
CORBA::Long GetNumberOfSegments();
void SetLocalLength(CORBA::Double segmentLength);
CORBA::Double GetLocalLength();
@ -85,12 +85,12 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_2D_i:
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
virtual bool getObjectsDependOn( std::vector< std::string > & /*entryArray*/,
std::vector< int > & /*subIDArray*/ ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
virtual bool setObjectsDependOn( std::vector< std::string > & /*entryArray*/,
std::vector< int > & /*subIDArray*/ ) { return true; }
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -63,12 +63,12 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_SimpleHypothesis_3D_i:
// Methods for copying mesh definition to other geometry
// Return geometry this hypothesis depends on. Return false if there is no geometry parameter
virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) const { return 0; }
virtual bool getObjectsDependOn( std::vector< std::string > & /*entryArray*/,
std::vector< int > & /*subIDArray*/ ) const { return 0; }
// Set new geometry instead of that returned by getObjectsDependOn()
virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
std::vector< int > & subIDArray ) { return true; }
virtual bool setObjectsDependOn( std::vector< std::string > & /*entryArray*/,
std::vector< int > & /*subIDArray*/ ) { return true; }
};
#endif

View File

@ -1,4 +1,4 @@
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@ -36,6 +36,8 @@
#include "NETGENPlugin_NETGEN_2D_ONLY_i.hxx"
#include "NETGENPlugin_NETGEN_2D_i.hxx"
#include "NETGENPlugin_NETGEN_3D_i.hxx"
#include "NETGENPlugin_NETGEN_3D_Remote_i.hxx"
#include "NETGENPlugin_NETGEN_2D_Remote_i.hxx"
#include "NETGENPlugin_SimpleHypothesis_2D_i.hxx"
#include "NETGENPlugin_SimpleHypothesis_3D_i.hxx"
@ -63,6 +65,10 @@ extern "C"
// Algorithms
if (strcmp(aHypName, "NETGEN_3D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_3D_i>;
else if (strcmp(aHypName, "NETGEN_3D_Remote") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_3D_Remote_i>;
else if (strcmp(aHypName, "NETGEN_2D_Remote") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_Remote_i>;
else if (strcmp(aHypName, "NETGEN_2D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_NETGEN_2D_i>;
else if (strcmp(aHypName, "NETGEN_2D_ONLY") == 0)
@ -86,7 +92,6 @@ extern "C"
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_SimpleHypothesis_3D_i>;
else if (strcmp(aHypName, "NETGEN_RemesherParameters_2D") == 0)
aCreator = new NETGENPlugin_Creator_i<NETGENPlugin_RemesherHypothesis_2D_i>;
else ;
return aCreator;
}

View File

@ -1,4 +1,4 @@
# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
# Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public