├── .dir-locals.el ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── dbg.yml │ ├── long-tests.yml │ └── main-job.yml ├── .gitignore ├── .tm_properties ├── .travis.yml ├── .vscode └── c_cpp_properties.json ├── AUTHORS ├── CMakeLists.txt ├── CONTRIBUTING.md ├── COPYING ├── COPYING.LESSER ├── Dockerfile ├── Jenkinsfile ├── LICENSE ├── README.md ├── _config.yml ├── cmake ├── config │ ├── CTestCustom.cmake │ └── mmgConfig.cmake.in ├── modules │ ├── FindElas.cmake │ ├── FindSCOTCH.cmake │ ├── LoadCiTests.cmake │ ├── add-mmg-options.cmake │ ├── add_build_types.cmake │ ├── build-targets.cmake │ ├── doxygen.cmake │ ├── macros.cmake │ ├── mmg.cmake │ ├── mmg2d.cmake │ ├── mmg2dConfig.cmake │ ├── mmg3d.cmake │ ├── mmg3dConfig.cmake │ ├── mmgConfig.cmake │ ├── mmgcommon.cmake │ ├── mmgs.cmake │ ├── mmgsConfig.cmake │ ├── optional-dependencies.cmake │ └── packages.cmake ├── testing │ ├── code │ │ ├── compare-para-tria.c │ │ ├── mmg2d_io.F90 │ │ ├── mmg_get_tagname.c │ │ ├── req-vert-3d.c │ │ ├── req-vert-s.c │ │ ├── ridge-preservation-in-ls-mode.c │ │ ├── test_met2d.c │ │ └── test_met3d.c │ ├── libmmg2d_tests.cmake │ ├── libmmg3d_tests.cmake │ ├── libmmg_tests.cmake │ ├── libmmgs_tests.cmake │ ├── mmg2d_tests.cmake │ ├── mmg3d_tests.cmake │ ├── mmg_tests.cmake │ └── mmgs_tests.cmake └── tools │ ├── FindMMG.cmake │ ├── FindMMG2D.cmake │ ├── FindMMG3D.cmake │ └── FindMMGS.cmake ├── codecov.yml ├── doc ├── doxygen │ ├── BUILD_DOXYGEN_DOC.md │ ├── Doxyfile.in │ ├── DoxygenLayout.xml │ ├── References.bib │ ├── custom.css │ └── logo-Mmg.png └── man │ ├── mmg2d.1.gz │ ├── mmg3d.1.gz │ └── mmgs.1.gz ├── libexamples ├── mmg │ ├── adaptation_example0 │ │ ├── README.md │ │ ├── cube.meshb │ │ ├── cube.solb │ │ ├── init.mesh │ │ ├── init.sol │ │ └── main.c │ ├── adaptation_example0_cpp │ │ ├── README.md │ │ ├── cube.meshb │ │ ├── cube.solb │ │ ├── init.mesh │ │ ├── init.sol │ │ └── main.cpp │ └── adaptation_example0_fortran │ │ ├── README.md │ │ ├── cube.meshb │ │ ├── cube.solb │ │ ├── init.mesh │ │ ├── init.sol │ │ └── main.F90 ├── mmg2d │ ├── IsosurfDiscretization_lsAndMetric │ │ ├── main.F90 │ │ ├── main.c │ │ ├── main_hsiz.F90 │ │ ├── main_hsiz.c │ │ ├── main_optim.F90 │ │ └── main_optim.c │ ├── IsosurfDiscretization_lsOnly │ │ ├── main.F90 │ │ ├── main.c │ │ ├── main_hsiz.F90 │ │ ├── main_hsiz.c │ │ ├── main_optim.F90 │ │ ├── main_optim.c │ │ ├── multi-mat-sol.sol │ │ └── multi-mat.mesh │ ├── adaptation_example0 │ │ ├── README.md │ │ ├── example0_a │ │ │ ├── init.mesh │ │ │ ├── init.sol │ │ │ └── main.c │ │ └── example0_b │ │ │ └── main.c │ ├── adaptation_example0_fortran │ │ ├── README.md │ │ ├── example0_a │ │ │ ├── init.mesh │ │ │ ├── init.sol │ │ │ └── main.F90 │ │ └── example0_b │ │ │ └── main.F90 │ ├── adaptation_example1 │ │ ├── README.md │ │ ├── dom.mesh │ │ └── main.c │ ├── adaptation_example2 │ │ ├── README.md │ │ └── main.c │ ├── adaptation_example3 │ │ ├── README.md │ │ └── main.c │ ├── io_multisols_example0 │ │ ├── README.md │ │ ├── main.F90 │ │ ├── main.c │ │ ├── naca-multiSols.mesh │ │ ├── naca-multiSols.sol │ │ └── visu.F90 │ └── squareGeneration_example0 │ │ ├── README.md │ │ ├── carretest.mesh │ │ └── main.c ├── mmg3d │ ├── IsosurfDiscretization_lsAndMetric │ │ ├── main.F90 │ │ ├── main.c │ │ ├── main_hsiz.F90 │ │ ├── main_hsiz.c │ │ ├── main_optim.F90 │ │ └── main_optim.c │ ├── IsosurfDiscretization_lsOnly │ │ ├── m.sol │ │ ├── main.F90 │ │ ├── main.c │ │ ├── main_hsiz.F90 │ │ ├── main_hsiz.c │ │ ├── main_optim.F90 │ │ ├── main_optim.c │ │ ├── met.mesh │ │ ├── met.sol │ │ └── plane.mesh │ ├── LagrangianMotion_example0 │ │ ├── README.md │ │ ├── main.c │ │ ├── tinyBoxt.mesh │ │ └── tinyBoxt.sol │ ├── adaptation_example0 │ │ ├── README.md │ │ ├── example0_a │ │ │ ├── cube.mesh │ │ │ ├── cube.sol │ │ │ └── main.c │ │ └── example0_b │ │ │ └── main.c │ ├── adaptation_example0_fortran │ │ ├── README.md │ │ ├── example0_a │ │ │ ├── cube.mesh │ │ │ ├── cube.sol │ │ │ └── main.F90 │ │ └── example0_b │ │ │ └── main.F90 │ ├── adaptation_example1 │ │ ├── README.md │ │ ├── main.c │ │ └── main.cold │ ├── adaptation_example2 │ │ ├── 2spheres.mesh │ │ ├── 2spheres.sol │ │ ├── README.md │ │ └── main.c │ ├── io_generic_and_get_adja │ │ ├── cube.mesh │ │ ├── cube.msh │ │ ├── cube.vtk │ │ ├── cube.vtu │ │ └── genericIO.c │ └── io_multisols_example6 │ │ ├── README.md │ │ ├── main.F90 │ │ ├── main.c │ │ ├── torus.mesh │ │ └── torus.sol └── mmgs │ ├── IsosurfDiscretization_example0 │ ├── README.md │ ├── main.c │ ├── teapot.mesh │ └── teapot.sol │ ├── IsosurfDiscretization_lsAndMetric │ ├── main.F90 │ ├── main.c │ ├── main_hsiz.F90 │ ├── main_hsiz.c │ ├── main_optim.F90 │ ├── main_optim.c │ └── multi-mat.mesh │ ├── IsosurfDiscretization_lsOnly │ ├── main.F90 │ ├── main.c │ ├── main_hsiz.F90 │ ├── main_hsiz.c │ ├── main_optim.F90 │ ├── main_optim.c │ ├── multi-mat-sol.sol │ └── multi-mat.mesh │ ├── adaptation_example0 │ ├── README.md │ ├── example0_a │ │ ├── cube.mesh │ │ ├── cube.sol │ │ └── main.c │ └── example0_b │ │ └── main.c │ ├── adaptation_example0_fortran │ ├── README.md │ ├── example0_a │ │ ├── README.md │ │ ├── cube.mesh │ │ ├── cube.sol │ │ └── main.F90 │ └── example0_b │ │ └── main.F90 │ ├── adaptation_example1 │ ├── 2spheres.mesh │ ├── 2spheres.sol │ ├── README.md │ └── main.c │ └── io_multisols_example3 │ ├── README.md │ ├── main.F90 │ ├── main.c │ ├── torus.mesh │ └── torus.sol ├── scripts ├── JENKINSFILE.sonarqube ├── genfort.pl ├── genheader.c └── git_log_mmg.sh └── src ├── common ├── API_functions.c ├── API_functionsf.c ├── analys.c ├── anisomovpt.c ├── anisosiz.c ├── apptools.c ├── bezier.c ├── boulep.c ├── chrono.c ├── chrono_private.h ├── eigenv.c ├── eigenv_private.h ├── hash.c ├── inlined_functions_private.h ├── inout.c ├── intmet.c ├── isosiz.c ├── libmmgcommon_private.h ├── libmmgtypes.h ├── librnbg.c ├── librnbg_private.h ├── libtools.c ├── mettools.c ├── mmg2.c ├── mmg2s.c ├── mmg3.c ├── mmg_core_export_private.h ├── mmg_export.h ├── mmgcmakedefines.h.in ├── mmgcmakedefinesf.h.in ├── mmgcommon_private.h ├── mmgexterns.c ├── mmgexterns_private.h ├── mmgversion.h.in ├── quality.c ├── scalem.c ├── tools.c ├── vtkparser.cpp └── vtkparser.hpp ├── mmg ├── libmmg.h └── libmmgf.h ├── mmg2d ├── API_functions_2d.c ├── API_functionsf_2d.c ├── analys_2d.c ├── anisomovpt_2d.c ├── anisosiz_2d.c ├── bezier_2d.c ├── boulep_2d.c ├── cenrad_2d.c ├── chkmsh_2d.c ├── colver_2d.c ├── delone_2d.c ├── enforcement_2d.c ├── hash_2d.c ├── inout_2d.c ├── inoutcpp_2d.cpp ├── intmet_2d.c ├── isosiz_2d.c ├── length_2d.c ├── libmmg2d.c ├── libmmg2d.h ├── libmmg2d_private.h ├── libmmg2d_tools.c ├── libmmg2d_toolsf.c ├── libmmg2df.c ├── lissmet_2d.c ├── locate_2d.c ├── mmg2d.c ├── mmg2d1.c ├── mmg2d2.c ├── mmg2d6.c ├── mmg2d9.c ├── mmg2d_export.h ├── mmg2dexterns.c ├── mmg2dexterns_private.h ├── movpt_2d.c ├── quality_2d.c ├── solmap_2d.c ├── split_2d.c ├── swapar_2d.c ├── tools_2d.c ├── variadic_2d.c ├── velextls_2d.c └── zaldy_2d.c ├── mmg3d ├── API_functions_3d.c ├── API_functionsf_3d.c ├── PRoctree_3d.c ├── PRoctree_3d_private.h ├── analys_3d.c ├── anisomovpt_3d.c ├── anisosiz_3d.c ├── bezier_3d.c ├── boulep_3d.c ├── cenrad_3d.c ├── chkmsh_3d.c ├── colver_3d.c ├── delaunay_3d.c ├── hash_3d.c ├── inlined_functions_3d_private.h ├── inout_3d.c ├── inoutcpp_3d.cpp ├── intmet_3d.c ├── isosiz_3d.c ├── libmmg3d.c ├── libmmg3d.h ├── libmmg3d_private.h ├── libmmg3d_tools.c ├── libmmg3d_toolsf.c ├── libmmg3df.c ├── librnbg_3d.c ├── mmg3d.c ├── mmg3d1.c ├── mmg3d1_delone.c ├── mmg3d1_pattern.c ├── mmg3d2.c ├── mmg3d2s.c ├── mmg3d3.c ├── mmg3d_export.h ├── mmg3dexterns.c ├── mmg3dexterns_private.h ├── movpt_3d.c ├── optbdry_3d.c ├── optlap_3d.c ├── opttyp_3d.c ├── quality_3d.c ├── split_3d.c ├── swap_3d.c ├── swapgen_3d.c ├── tools_3d.c ├── variadic_3d.c ├── velextls_3d.c └── zaldy_3d.c └── mmgs ├── API_functions_s.c ├── API_functionsf_s.c ├── analys_s.c ├── anisomovpt_s.c ├── anisosiz_s.c ├── bezier_s.c ├── boulep_s.c ├── chkmsh_s.c ├── colver_s.c ├── gentools_s.c ├── hash_s.c ├── inout_s.c ├── inoutcpp_s.cpp ├── intmet_s.c ├── isosiz_s.c ├── libmmgs.c ├── libmmgs.h ├── libmmgs_private.h ├── libmmgs_tools.c ├── libmmgs_toolsf.c ├── libmmgsf.c ├── librnbg_s.c ├── mmgs.c ├── mmgs1.c ├── mmgs2.c ├── mmgs_export.h ├── mmgsexterns.c ├── mmgsexterns_private.h ├── movpt_s.c ├── quality_s.c ├── split_s.c ├── swapar_s.c ├── variadic_s.c └── zaldy_s.c /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;; Set emacs indentation 2 | 3 | ((nil . ( 4 | (fill-column . 80 ) 5 | (indent-tabs-mode . nil) 6 | (tab-width . 2 ) 7 | (show-trailing-whitespace . t ) 8 | ) 9 | ) 10 | 11 | (c-mode . ( 12 | (indent-tabs-mode . nil) 13 | (c-file-style . "linux") 14 | (c-basic-offset . 2 ))) 15 | 16 | (cmake-mode . ( 17 | (cmake-file-style . "linux") 18 | (cmake-tab-width . 2 ))) 19 | ) 20 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ['https://www.mmgtools.org/mmg-open-source-consortium'] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'kind: bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. Do not hesitate to add screenshots or terminal outputs to help explain your problem. 12 | 13 | **Technical context (please complete the following information):** 14 | - OS: [e.g. Ubuntu-24.04, MacOS Sonoma-14.3.1,...] 15 | - Architecture: [e.g. x86_64, Apple M1 Max,... ] 16 | - Mmg version or git commit hash: [e.g. `v5.5.1` , ...] 17 | - Compiler version: [e.g. `Apple clang version 15.0.0 (clang-1500.1.0.2.5)` , `gcc-9 (Homebrew GCC 9.5.0) 9.5.0`,... ] 18 | - Mmg call: [e.g. through command line, in library mode using its API, ... ] 19 | 20 | **To Reproduce** 21 | Steps to reproduce the behavior: 22 | 1. Command line or provided arguments: ... 23 | 2. ... 24 | 3. See error 25 | 26 | **Expected behavior** 27 | A clear and concise description of what you expected to happen. 28 | 29 | **Additional context** 30 | Add any other context about the problem here. 31 | -------------------------------------------------------------------------------- /.github/workflows/long-tests.yml: -------------------------------------------------------------------------------- 1 | name: Long tests 2 | 3 | on: 4 | # run tests on push events 5 | push: 6 | # run tests on PR events 7 | pull_request: 8 | types: [opened, synchronize] 9 | 10 | # run tests manually on a given branch (default is master) 11 | workflow_dispatch: 12 | # Inputs the workflow accepts. 13 | inputs: 14 | branch: 15 | # branch to test 16 | description: 'branch to test' 17 | # Default value if no value is explicitly provided 18 | default: 'master' 19 | required: false 20 | 21 | # job 22 | jobs: 23 | mmg-debug: 24 | uses: ./.github/workflows/main-job.yml 25 | with: 26 | cmake_build_type: RelWithAssert 27 | add_cmake_cfg_args: -D LONG_TESTS=ON 28 | branch_name: ${{github.event.inputs.branch}} 29 | code_coverage: true 30 | secrets: inherit 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CTestConfig.cmake 3 | *~ 4 | *.swp 5 | 6 | archives 7 | bin 8 | build*/* 9 | build/* 10 | 11 | doc/doxygen/*/Doxyfile 12 | doc/doxygen/*/html 13 | doc/doxygen/*/latex 14 | doc/doxygen/man 15 | 16 | lib 17 | 18 | libexamples/*/*/mainTESTADJA.c 19 | libexamples/*/*/*/mesh.* 20 | libexamples/*/*/result0.* 21 | libexamples/*/*/2spheres_* 22 | libexamples/*/*/*.o* 23 | libexamples/*/*/mesh.* 24 | libexamples/*/*/cube.3d.* 25 | libexamples/*/*/cube.s.* 26 | libexamples/*/*/result.* 27 | 28 | ci_tests 29 | 30 | src/common/mmg.h 31 | 32 | include/* 33 | *.o 34 | 35 | .DS_Store 36 | .vscode 37 | 38 | TAGS 39 | .scannerwork/* 40 | sonar-project.properties 41 | -------------------------------------------------------------------------------- /.tm_properties: -------------------------------------------------------------------------------- 1 | ## Set TextMate indentation 2 | encoding = UTF-8 3 | softWrap = true 4 | tabSize = 2 5 | # invisiblesMap = true 6 | 7 | [ *] 8 | softTabs = true 9 | 10 | [ {CMakeLists.txt,*.cmake} ] 11 | fileType = "source.CMakeListfile" 12 | 13 | [ *.{c,h,h.in} ] 14 | fileType = "source.c" -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | language: cpp 4 | 5 | services: 6 | - docker 7 | 8 | before_install: 9 | - travis_retry docker build -t mmgtools/mmg-dev . 10 | 11 | script: 12 | - | 13 | docker run -v $PWD:/home/travis/src --name mmg-dev mmgtools/mmg-dev bash -c \ 14 | "mkdir -p $HOME/src/build && \ 15 | cd $HOME/src/build && \ 16 | cmake -D CMAKE_BUILD_TYPE=Debug -D BUILD_TESTING=ON .. && \ 17 | make && \ 18 | ctest" 19 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/usr/lib/x86_64-linux-gnu/openmpi/include", 8 | "/usr/local/include/vtk-9.2/**", 9 | "/home/lmottet/Work/Software/ParMmg/**", 10 | "/home/lmottet/Work/Software/mmg/**", 11 | "/home/lmottet/Work/Software/mmg/build-dev/include/**", 12 | "/home/lmottet/Work/Software/mmg/build-dev/lib/**", 13 | "/home/lmottet/Work/Software/mmg/build-*/include/**", 14 | "/home/lmottet/Work/Software/mmg/build-*/lib/**" 15 | 16 | ], 17 | "defines": [], 18 | "compilerPath": "/usr/bin/mpirun", 19 | "cStandard": "gnu17", 20 | "cppStandard": "gnu++14", 21 | "intelliSenseMode": "linux-gcc-x64" 22 | } 23 | ], 24 | "version": 4 25 | } 26 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | MMG Authors 2 | ============== 3 | 4 | The following cumulative list contains the names of all individuals who have committed code to the MMG3D5 repository. 5 | 6 | Name Affiliation(s) 7 | --------------------------- -------------------- 8 | Cécile Dobrzynski Inria / Université de Bordeaux, IMB 9 | Charles Dapogny UPMC, LJLL 10 | Pascal Frey UPMC, LJLL 11 | Algiane Froehly Inria / Université de Bordeaux, IMB 12 | Cédric Lachat Inria / Université de Bordeaux, Labri 13 | Xavier Lacoste Inria / Université de Bordeaux, Labri 14 | 15 | Affiliation abbreviations: 16 | ------------------------- 17 | IMB = Institut de mathématiques de Bordeaux (University of Bordeaux) 18 | LJLL = Laboratoire Jacques-Louis Lions 19 | UPMC = Université Pierre et Marie Curie 20 | 21 | Contact: 22 | -------- 23 | contact@mmgtools.org 24 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Customize the official Debian container to allow Pipeline building of MMG 2 | # David Sherman 2017-02-07 3 | 4 | FROM debian 5 | 6 | USER root 7 | 8 | ## Standard build tools 9 | RUN apt-get update && \ 10 | apt-get install -y sudo build-essential git cmake doxygen 11 | 12 | ## Optional module Scotch 13 | RUN apt-get install -y curl zlib1g-dev 14 | RUN curl -L -O http://gforge.inria.fr/frs/download.php/latestfile/298/scotch_6.0.4.tar.gz && \ 15 | tar xzf scotch_6.0.4.tar.gz && \ 16 | ( cd scotch_6.0.4/src && \ 17 | ln -s Make.inc/Makefile.inc.x86-64_pc_linux2 Makefile.inc && \ 18 | make scotch prefix=/usr && make install ) && \ 19 | rm -rf scotch_6.0.4.tar.gz scotch_6.0.4 20 | 21 | ## Optional module LinearElasticity 22 | RUN git clone https://github.com/ICStoolbox/Commons.git && \ 23 | mkdir -p Commons/build && \ 24 | ( cd Commons/build && HOME=/usr cmake .. && make && make install ) && \ 25 | git clone https://github.com/ICStoolbox/LinearElasticity.git && \ 26 | mkdir -p LinearElasticity/build && \ 27 | ( cd LinearElasticity/build && HOME=/usr cmake .. && make && make install ) && \ 28 | rm -rf Commons LinearElasticity 29 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | #!groovy 2 | 3 | // Jenkinsfile for compiling, testing, and packaging MMG 4 | 5 | 6 | pipeline { 7 | agent { 8 | dockerfile true 9 | } 10 | stages { 11 | stage('Checkout') { 12 | steps { 13 | checkout scm 14 | sh 'mkdir -p build local' 15 | } 16 | } 17 | stage('Compile') { 18 | steps { 19 | sh ''' 20 | cd build && 21 | cmake -D CMAKE_BUILD_TYPE=Debug -D BUILD_TESTING=ON .. && 22 | make 23 | ''' 24 | } 25 | } 26 | stage('Test') { 27 | steps { 28 | sh ''' 29 | cd build && 30 | ctest 31 | ''' 32 | } 33 | } 34 | stage('Package') { 35 | steps { 36 | sh ''' 37 | cd build && 38 | cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_TESTING=OFF -D CMAKE_INSTALL_PREFIX:PATH=$PWD/../local .. 39 | make 40 | make install 41 | ''' 42 | archiveArtifacts artifacts: 'local/**', fingerprint: true, onlyIfSuccessful: true 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | mmg Copyright / License Information 2 | ====================================== 3 | 4 | This file is part of the mmg software package for the tetrahedral mesh modification. 5 | Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 6 | 7 | mmg 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 3 of the License, or (at your option) any later version. 8 | 9 | mmg 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. 10 | 11 | You should have received a copy of the GNU Lesser General Public License and of the GNU General Public License along with mmg (in files COPYING.LESSER and COPYING). If not, see . Please read their terms carefully and use this copy of the mmg distribution only if you accept them. 12 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /cmake/config/CTestCustom.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ##** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | SET( CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 5000) 24 | SET( CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS 2000) 25 | 26 | SET ( CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} 27 | ".*: warning: array subscript has type 'char'.*") 28 | SET ( CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} 29 | ".*: warning: array subscript has type ‘char’.*") 30 | SET (CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 0 ) 31 | SET (CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 0 ) 32 | -------------------------------------------------------------------------------- /cmake/config/mmgConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(CMakeFindDependencyMacro) 4 | 5 | # Allows us to use all .cmake files in this directory 6 | # required for `find_dependency({SCOTCH,VTK}) to work. 7 | list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}") 8 | 9 | if("@SCOTCH_FOUND@" AND NOT "@USE_SCOTCH@" MATCHES OFF) 10 | find_dependency(SCOTCH) 11 | endif() 12 | 13 | if("@VTK_FOUND@" AND NOT "@USE_VTK@" MATCHES OFF) 14 | find_dependency(VTK) 15 | endif() 16 | 17 | if (NOT TARGET Mmg::mmg ) 18 | include(${CMAKE_CURRENT_LIST_DIR}/MmgTargets.cmake) 19 | endif () 20 | -------------------------------------------------------------------------------- /cmake/modules/FindElas.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ##** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | IF ((NOT WIN32) AND (NOT WIN64)) 24 | SET ( ELAS_INCLUDE_DIR ELAS_INCLUDE_DIR-NOTFOUND ) 25 | SET ( ELAS_LIBRARY ELAS_LIBRARY-NOTFOUND ) 26 | ENDIF() 27 | 28 | FIND_PATH(ELAS_INCLUDE_DIR 29 | NAMES elastic.h 30 | HINTS ${ELAS_INCLUDE_DIR} 31 | $ENV{ELAS_INCLUDE_DIR} 32 | $ENV{HOME}/include 33 | ${ELAS_DIR}/include 34 | $ENV{ELAS_DIR}/include 35 | ${ELAS_DIR}/sources 36 | $ENV{ELAS_DIR}/sources 37 | PATH_SUFFIXES ELAS 38 | DOC "Directory of ELAS Header") 39 | 40 | # Check for elas library (search in common locations in order to prevent 41 | # modifications in ELAS installation) 42 | FIND_LIBRARY(ELAS_LIBRARY 43 | NAMES Elas Elas${ELAS_LIB_SUFFIX} 44 | HINTS ${ELAS_LIBRARY} 45 | $ENV{ELAS_LIBRARY} 46 | $ENV{HOME}/lib 47 | ${ELAS_DIR}/lib 48 | $ENV{ELAS_DIR}/lib 49 | DOC "The ELAS library" 50 | ) 51 | 52 | INCLUDE(FindPackageHandleStandardArgs) 53 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(ELAS DEFAULT_MSG 54 | ELAS_INCLUDE_DIR ELAS_LIBRARY) 55 | IF ((NOT WIN32) AND (NOT WIN64)) 56 | MARK_AS_ADVANCED(ELAS_INCLUDE_DIR ELAS_LIBRARY) 57 | ENDIF() 58 | -------------------------------------------------------------------------------- /cmake/modules/add-mmg-options.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ## Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | #------------------------------- static or shared libs 24 | FUNCTION (INVERT_BOOL OUTVAR INVAR) 25 | IF(${INVAR}) 26 | SET(${OUTVAR} OFF PARENT_SCOPE) 27 | ELSE() 28 | SET(${OUTVAR} ON PARENT_SCOPE) 29 | ENDIF() 30 | ENDFUNCTION() 31 | 32 | OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF) 33 | INVERT_BOOL("BUILD_STATIC_LIBS" ${BUILD_SHARED_LIBS}) 34 | IF ( (${BUILD_STATIC_LIBS} EQUAL ON) AND NOT CMAKE_POSITION_INDEPENDENT_CODE) 35 | SET(CMAKE_POSITION_INDEPENDENT_CODE ON) 36 | ENDIF() 37 | 38 | #------------------------------- mmg2d 39 | CMAKE_DEPENDENT_OPTION ( LIBMMG2D_STATIC "Compile the mmg2d static library" ON 40 | "BUILD_MMG2D;BUILD_STATIC_LIBS" OFF) 41 | CMAKE_DEPENDENT_OPTION ( LIBMMG2D_SHARED "Compile the mmg2d dynamic library" ON 42 | "BUILD_MMG2D;BUILD_SHARED_LIBS" OFF ) 43 | IF (LIBMMG2D_STATIC OR LIBMMG2D_SHARED) 44 | SET(LIBMMG2D_INTERNAL ON ) 45 | ELSE() 46 | SET(LIBMMG2D_INTERNAL OFF ) 47 | ENDIF() 48 | CMAKE_DEPENDENT_OPTION ( 49 | TEST_LIBMMG2D "Build mmg2d library examples and tests" OFF 50 | "BUILD_MMG2D;LIBMMG2D_INTERNAL" OFF) 51 | 52 | CMAKE_DEPENDENT_OPTION( 53 | MMG2D_CI "Enable/Disabletest_execution for mmg2d" ON 54 | "BUILD_TESTING;BUILD_MMG2D" OFF) 55 | 56 | #------------------------------- mmgs 57 | CMAKE_DEPENDENT_OPTION ( LIBMMGS_STATIC "Compile the mmgs static library" ON 58 | "BUILD_MMGS;BUILD_STATIC_LIBS" OFF) 59 | CMAKE_DEPENDENT_OPTION ( LIBMMGS_SHARED "Compile the mmgs dynamic library" ON 60 | "BUILD_MMGS;BUILD_SHARED_LIBS" OFF) 61 | IF (LIBMMGS_STATIC OR LIBMMGS_SHARED) 62 | SET(LIBMMGS_INTERNAL ON ) 63 | ELSE() 64 | SET(LIBMMGS_INTERNAL OFF ) 65 | ENDIF() 66 | CMAKE_DEPENDENT_OPTION ( 67 | TEST_LIBMMGS "Build mmgs library examples and tests" OFF 68 | "LIBMMGS_INTERNAL;BUILD_MMGS" OFF 69 | ) 70 | 71 | CMAKE_DEPENDENT_OPTION( 72 | MMGS_CI "Enable/Disable test_execution for mmgs" ON 73 | "BUILD_TESTING;BUILD_MMGS" OFF ) 74 | 75 | #------------------------------- mmg3d 76 | CMAKE_DEPENDENT_OPTION ( LIBMMG3D_STATIC "Compile the mmg3d static library" ON 77 | "BUILD_MMG3D;BUILD_STATIC_LIBS" OFF ) 78 | CMAKE_DEPENDENT_OPTION ( LIBMMG3D_SHARED "Compile the mmg3d dynamic library" ON 79 | "BUILD_MMG3D;BUILD_SHARED_LIBS" OFF ) 80 | IF (LIBMMG3D_STATIC OR LIBMMG3D_SHARED) 81 | SET(LIBMMG3D_INTERNAL ON ) 82 | ELSE() 83 | SET(LIBMMG3D_INTERNAL OFF ) 84 | ENDIF() 85 | CMAKE_DEPENDENT_OPTION ( 86 | TEST_LIBMMG3D "Build mmg3d library examples and tests" OFF 87 | "BUILD_MMG3D;LIBMMG3D_INTERNAL" OFF 88 | ) 89 | CMAKE_DEPENDENT_OPTION( 90 | MMG3D_CI "Enable/Disable test execution for mmg3d" ON 91 | "BUILD_TESTING;BUILD_MMG3D" OFF) 92 | 93 | CMAKE_DEPENDENT_OPTION ( MMG_PATTERN 94 | "If ON, insertion by patterns, otherwise insertion by delaunay kernel" 95 | OFF 96 | "BUILD_MMG3D" OFF) 97 | #-- Remove the next line to have this option visible in basic cmake mode 98 | MARK_AS_ADVANCED(MMG_PATTERN) 99 | 100 | #---------------------------- mmg library gathering mmg2d, mmgs and mmg3d libs 101 | CMAKE_DEPENDENT_OPTION ( LIBMMG_STATIC 102 | "Compile the mmg static library (mmg2d + mmgs + mmg3d)" ON 103 | "BUILD_MMG;BUILD_STATIC_LIBS" OFF) 104 | CMAKE_DEPENDENT_OPTION ( LIBMMG_SHARED 105 | "Compile the mmg dynamic library (mmg2d + mmgs + mmg3d)" ON 106 | "BUILD_MMG;BUILD_SHARED_LIBS" OFF ) 107 | IF (LIBMMG_STATIC OR LIBMMG_SHARED) 108 | SET(LIBMMG_INTERNAL ON ) 109 | ELSE() 110 | SET(LIBMMG_INTERNAL OFF ) 111 | ENDIF() 112 | CMAKE_DEPENDENT_OPTION ( 113 | TEST_LIBMMG "Build mmg library examples and tests" OFF 114 | "BUILD_MMG;LIBMMG_INTERNAL" OFF 115 | ) 116 | CMAKE_DEPENDENT_OPTION( 117 | MMG_CI "Enable/Disable test execution for mmg library" ON 118 | "BUILD_TESTING;BUILD_MMG" OFF) 119 | 120 | #---------------------- install provate headers for library built on top of Mmg 121 | OPTION ( MMG_INSTALL_PRIVATE_HEADERS 122 | "Install private headers of Mmg (use at your own risk)" OFF ) 123 | -------------------------------------------------------------------------------- /cmake/modules/build-targets.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ## Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) 24 | 25 | # CTEST_OUTPUT_DIR MUST BE SETTED HERE TO AVOID UNINITIALIZATION FOR LIBRARY 26 | # TESTS DEFS 27 | OPTION ( BUILD_TESTING "Enable/Disable continuous integration" OFF ) 28 | 29 | IF( BUILD_TESTING ) 30 | SET ( CTEST_OUTPUT_DIR ${PROJECT_BINARY_DIR}/TEST_OUTPUTS 31 | CACHE PATH "Path toward the tests outputs" ) 32 | MARK_AS_ADVANCED ( CTEST_OUTPUT_DIR ) 33 | FILE ( MAKE_DIRECTORY ${CTEST_OUTPUT_DIR} ) 34 | ENDIF ( ) 35 | 36 | INCLUDE(mmgcommon) 37 | 38 | IF ( BUILD_MMG2D ) 39 | INCLUDE(mmg2d) 40 | ENDIF ( ) 41 | 42 | IF ( BUILD_MMGS ) 43 | INCLUDE(mmgs) 44 | ENDIF ( ) 45 | 46 | IF ( BUILD_MMG3D ) 47 | INCLUDE(mmg3d) 48 | ENDIF ( ) 49 | 50 | IF ( BUILD_MMG ) 51 | INCLUDE(mmg) 52 | ENDIF ( ) 53 | 54 | IF ( MmgTargetsExported ) 55 | set( MMG_CMAKE_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/mmg ) 56 | 57 | configure_package_config_file(cmake/config/mmgConfig.cmake.in 58 | ${PROJECT_BINARY_DIR}/mmgConfig.cmake 59 | INSTALL_DESTINATION ${MMG_CMAKE_INSTALL_DIR} ) 60 | 61 | install(EXPORT MmgTargets 62 | FILE MmgTargets.cmake 63 | NAMESPACE Mmg:: 64 | DESTINATION ${MMG_CMAKE_INSTALL_DIR} 65 | ) 66 | install(FILES ${PROJECT_BINARY_DIR}/mmgConfig.cmake 67 | DESTINATION ${MMG_CMAKE_INSTALL_DIR} ) 68 | 69 | install(FILES 70 | ${PROJECT_SOURCE_DIR}/cmake/modules/FindSCOTCH.cmake 71 | ${PROJECT_SOURCE_DIR}/cmake/modules/FindElas.cmake 72 | DESTINATION ${MMG_CMAKE_INSTALL_DIR} ) 73 | ENDIF() 74 | -------------------------------------------------------------------------------- /cmake/modules/doxygen.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ##** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | # Build Doxygen doc if needed 24 | OPTION ( BUILD_DOC "Enable/Disable Doxygen documentation target" OFF ) 25 | IF ( BUILD_DOC ) 26 | FIND_PACKAGE(Doxygen) 27 | IF(DOXYGEN_FOUND) 28 | 29 | # MMG Documentation 30 | SET( MMG_DOC_DIR ${PROJECT_BINARY_DIR}/doc/ CACHE PATH 31 | "Path toward generated Doxygen doc.") 32 | mark_as_advanced(MMG_DOC_DIR) 33 | 34 | FILE(MAKE_DIRECTORY ${MMG_DOC_DIR}) 35 | 36 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/doc/doxygen/Doxyfile.in 37 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) 38 | ADD_CUSTOM_TARGET(doc 39 | COMMAND ${DOXYGEN_EXECUTABLE} 40 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 41 | WORKING_DIRECTORY ${MMG_DOC_DIR} 42 | COMMENT "Generating Mmg documentation with Doxygen. Open up the 43 | ${MMG_DOC_DIR}/index.html file to see 44 | it" VERBATIM ) 45 | 46 | ENDIF ( DOXYGEN_FOUND ) 47 | ENDIF ( ) 48 | -------------------------------------------------------------------------------- /cmake/modules/mmg2dConfig.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/mmg2dTargets.cmake") 2 | -------------------------------------------------------------------------------- /cmake/modules/mmg3dConfig.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/mmg3dTargets.cmake") 2 | -------------------------------------------------------------------------------- /cmake/modules/mmgConfig.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/mmgTargets.cmake") 2 | -------------------------------------------------------------------------------- /cmake/modules/mmgsConfig.cmake: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/mmgsTargets.cmake") 2 | -------------------------------------------------------------------------------- /cmake/modules/packages.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ## Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | ############################################################################### 24 | ##### 25 | ##### Create Package 26 | ##### 27 | ############################################################################### 28 | 29 | INCLUDE(InstallRequiredSystemLibraries) 30 | SET( CPACK_ARCHIVE_COMPONENT_INSTALL ON ) 31 | SET( CPACK_COMPONENT_ALL appli ) 32 | SET( CPACK_SOURCE_GENERATOR TGZ ) 33 | SET( CPACK_GENERATOR TGZ ) 34 | 35 | SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) 36 | SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1) 37 | SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MMG: 2d, surface and 3d remeshers") 38 | SET(CPACK_PACKAGE_VENDOR "Cécile Dobrzynski, Pascal Frey, Charles Dapogny," 39 | " Algiane Froehly") 40 | SET(CPACK_PACKAGE_CONTACT "contact@mmgtools.org") 41 | SET(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md") 42 | SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") 43 | SET(CPACK_PACKAGE_VERSION ${CMAKE_RELEASE_VERSION}) 44 | SET(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_RELEASE_VERSION_MAJOR}) 45 | SET(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_RELEASE_VERSION_MINOR}) 46 | SET(CPACK_PACKAGE_VERSION_PATCH ${CMAKE_RELEASE_VERSION_PATCH}) 47 | SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}") 48 | SET(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_INSTALL_DIRECTORY}-${CMAKE_SYSTEM}) 49 | SET(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}") 50 | SET(CPACK_OUTPUT_FILE_PREFIX "../archives") 51 | 52 | INCLUDE(CPack) 53 | -------------------------------------------------------------------------------- /cmake/testing/code/mmg_get_tagname.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "libmmgcommon_private.h" 5 | 6 | int main() { 7 | 8 | uint16_t tag; 9 | char *tags_name; 10 | 11 | tag = 0; 12 | printf("%s\n", MMG5_Get_tagName(tag)); 13 | 14 | tag = UINT16_MAX; 15 | printf("%s\n", MMG5_Get_tagName(tag)); 16 | 17 | tag &= ~MG_NUL; 18 | printf("%s\n", MMG5_Get_tagName(tag)); 19 | 20 | 21 | return 0; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /cmake/testing/code/req-vert-3d.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * Test preservation of required vertex: vertex 1 is required and shoule not move. 26 | * 27 | * \author Charles Dapogny (LJLL, UPMC) 28 | * \author Cécile Dobrzynski (Inria / IMB, Université de Bordeaux) 29 | * \author Pascal Frey (LJLL, UPMC) 30 | * \author Algiane Froehly (Inria / IMB, Université de Bordeaux) 31 | * \version 5 32 | * \copyright GNU Lesser General Public License. 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | /** Include the mmg3d library hader file */ 45 | // if the header file is in the "include" directory 46 | // #include "libmmg3d.h" 47 | // if the header file is in "include/mmg/mmg3d" 48 | #include "libmmg3d_private.h" 49 | #include "mmg/mmg3d/libmmg3d.h" 50 | 51 | int main(int argc,char *argv[]) { 52 | MMG5_pMesh mesh; 53 | MMG5_pSol sol; 54 | char *file; 55 | double c[3]; 56 | int k,ier; 57 | 58 | fprintf(stdout," -- CHECK PRESERVATION OF REQUIRED VERTICES \n"); 59 | 60 | if ( argc != 2 ) { 61 | printf(" Usage: %s filein \n",argv[0]); 62 | return(1); 63 | } 64 | 65 | /* Name and path of the mesh file */ 66 | file = (char *) calloc(strlen(argv[1]) + 1, sizeof(char)); 67 | if ( file == NULL ) { 68 | perror(" ## Memory problem: calloc"); 69 | exit(EXIT_FAILURE); 70 | } 71 | strcpy(file,argv[1]); 72 | 73 | /** Read mesh */ 74 | mesh = NULL; 75 | sol = NULL; 76 | MMG3D_Init_mesh(MMG5_ARG_start, 77 | MMG5_ARG_ppMesh,&mesh, 78 | MMG5_ARG_ppMet,&sol, 79 | MMG5_ARG_end); 80 | 81 | if ( MMG3D_loadMesh(mesh,file) != 1 ) { 82 | fprintf(stderr,"Error: %s: %d: File not found %s\n.",__func__,__LINE__,file); 83 | exit(EXIT_FAILURE); 84 | } 85 | 86 | /** Check that vertex number 1 is required and store its coordinates */ 87 | if ( !(mesh->point[1].tag & MG_REQ) ) { 88 | fprintf(stderr,"Error: %s: %d: This test expects that vertex of index 1 is required\n.",__func__,__LINE__); 89 | exit(EXIT_FAILURE); 90 | } 91 | c[0] = mesh->point[1].c[0]; 92 | c[1] = mesh->point[1].c[1]; 93 | c[2] = mesh->point[1].c[2]; 94 | 95 | /** Enable vertex regularisation */ 96 | if ( MMG3D_Set_iparameter(mesh,sol,MMG3D_IPARAM_xreg,1) != 1 ) 97 | exit(EXIT_FAILURE); 98 | 99 | /** remesh function */ 100 | ier = MMG3D_mmg3dlib(mesh,sol); 101 | 102 | 103 | /** Check that coordinates of vertex 1 (that is required) have not changed. */ 104 | double dd[3]; 105 | dd[0] = c[0] - mesh->point[1].c[0]; 106 | dd[1] = c[1] - mesh->point[1].c[1]; 107 | dd[2] = c[2] - mesh->point[1].c[2]; 108 | 109 | 110 | int j; 111 | for (j=0; j<3; ++j) { 112 | printf("%.15lf %.15lf\n",c[j],mesh->point[1].c[j]); 113 | if ( fabs(c[j]- mesh->point[1].c[j]) > 1e-5 ) { 114 | fprintf(stderr,"Error: %s: %d:" 115 | " Modification of coordinates of vertex 1 (required):" 116 | " input coor: %15lf %15lf %15lf\n" 117 | " output coor: %15lf %15lf %15lf\n",__func__,__LINE__, 118 | c[0],c[1],c[2], mesh->point[1].c[0], mesh->point[1].c[1], mesh->point[1].c[2]); 119 | exit(EXIT_FAILURE); 120 | } 121 | } 122 | 123 | fprintf(stdout,"MMG3D: REQUIRED VERTEX SUCCESFULLY PRESERVED.\n"); 124 | 125 | /** 3) Free the MMG3D5 structures */ 126 | MMG3D_Free_all(MMG5_ARG_start, 127 | MMG5_ARG_ppMesh,&mesh, 128 | MMG5_ARG_ppMet,&sol, 129 | MMG5_ARG_end); 130 | 131 | free(file); 132 | file = NULL; 133 | 134 | return 0; 135 | } 136 | -------------------------------------------------------------------------------- /cmake/testing/code/req-vert-s.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * Test preservation of required vertex: vertex 1 is required and shoule not move. 26 | * 27 | * \author Charles Dapogny (LJLL, UPMC) 28 | * \author Cécile Dobrzynski (Inria / IMB, Université de Bordeaux) 29 | * \author Pascal Frey (LJLL, UPMC) 30 | * \author Algiane Froehly (Inria / IMB, Université de Bordeaux) 31 | * \version 5 32 | * \copyright GNU Lesser General Public License. 33 | */ 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | /** Include the mmg3d library hader file */ 45 | // if the header file is in the "include" directory 46 | // #include "libmmg3d.h" 47 | // if the header file is in "include/mmg/mmg3d" 48 | #include "libmmgs_private.h" 49 | #include "mmg/mmgs/libmmgs.h" 50 | 51 | int main(int argc,char *argv[]) { 52 | MMG5_pMesh mesh; 53 | MMG5_pSol sol; 54 | char *file; 55 | double c[3]; 56 | int k,ier; 57 | 58 | fprintf(stdout," -- CHECK PRESERVATION OF REQUIRED VERTICES \n"); 59 | 60 | if ( argc != 2 ) { 61 | printf(" Usage: %s filein \n",argv[0]); 62 | return(1); 63 | } 64 | 65 | /* Name and path of the mesh file */ 66 | file = (char *) calloc(strlen(argv[1]) + 1, sizeof(char)); 67 | if ( file == NULL ) { 68 | perror(" ## Memory problem: calloc"); 69 | exit(EXIT_FAILURE); 70 | } 71 | strcpy(file,argv[1]); 72 | 73 | /** Read mesh */ 74 | mesh = NULL; 75 | sol = NULL; 76 | MMGS_Init_mesh(MMG5_ARG_start, 77 | MMG5_ARG_ppMesh,&mesh, 78 | MMG5_ARG_ppMet,&sol, 79 | MMG5_ARG_end); 80 | 81 | if ( MMGS_loadMesh(mesh,file) != 1 ) { 82 | fprintf(stderr,"Error: %s: %d: File not found %s\n.",__func__,__LINE__,file); 83 | exit(EXIT_FAILURE); 84 | } 85 | 86 | /** Check that vertex number 1 is required and store its coordinates */ 87 | if ( !(mesh->point[1].tag & MG_REQ) ) { 88 | fprintf(stderr,"Error: %s: %d: This test expects that vertex of index 1 is required\n.",__func__,__LINE__); 89 | exit(EXIT_FAILURE); 90 | } 91 | c[0] = mesh->point[1].c[0]; 92 | c[1] = mesh->point[1].c[1]; 93 | c[2] = mesh->point[1].c[2]; 94 | 95 | /** Enable vertex regularisation */ 96 | if ( MMGS_Set_iparameter(mesh,sol,MMGS_IPARAM_xreg,1) != 1 ) 97 | exit(EXIT_FAILURE); 98 | 99 | /** remesh function */ 100 | ier = MMGS_mmgslib(mesh,sol); 101 | 102 | 103 | /** Check that coordinates of vertex 1 (that is required) have not changed. */ 104 | double dd[3]; 105 | dd[0] = c[0] - mesh->point[1].c[0]; 106 | dd[1] = c[1] - mesh->point[1].c[1]; 107 | dd[2] = c[2] - mesh->point[1].c[2]; 108 | 109 | 110 | int j; 111 | for (j=0; j<3; ++j) { 112 | printf("%.15lf %.15lf\n",c[j],mesh->point[1].c[j]); 113 | if ( fabs(c[j]- mesh->point[1].c[j]) > 1e-5 ) { 114 | fprintf(stderr,"Error: %s: %d:" 115 | " Modification of coordinates of vertex 1 (required):" 116 | " input coor: %15lf %15lf %15lf\n" 117 | " output coor: %15lf %15lf %15lf\n",__func__,__LINE__, 118 | c[0],c[1],c[2], mesh->point[1].c[0], mesh->point[1].c[1], mesh->point[1].c[2]); 119 | exit(EXIT_FAILURE); 120 | } 121 | } 122 | 123 | fprintf(stdout,"MMGS: REQUIRED VERTEX SUCCESFULLY PRESERVED.\n"); 124 | 125 | /** 3) Free the MMG structures */ 126 | MMGS_Free_all(MMG5_ARG_start, 127 | MMG5_ARG_ppMesh,&mesh, 128 | MMG5_ARG_ppMet,&sol, 129 | MMG5_ARG_end); 130 | 131 | free(file); 132 | file = NULL; 133 | 134 | return 0; 135 | } 136 | -------------------------------------------------------------------------------- /cmake/testing/code/test_met2d.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Test matrix algebra in 2D. 3 | * 4 | * \author Luca Cirrottola (Inria) 5 | * \version 1 6 | * \copyright GNU Lesser General Public License. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | /** Include the mmg2d library header file */ 19 | // if the header file is in the "include" directory 20 | // #include "libmmg2d.h" 21 | // if the header file is in "include/mmg/mmg2d" 22 | #include "mmg/mmg2d/libmmg2d.h" 23 | #include "mmgcommon_private.h" 24 | 25 | int main(int argc,char *argv[]) { 26 | MMG5_pMesh mmgMesh; 27 | MMG5_pSol mmgSol; 28 | 29 | fprintf(stdout," -- TEST MATRIX ALGEBRA IN 2D \n"); 30 | 31 | if ( argc != 1 ) { 32 | printf(" Usage: %s\n",argv[0]); 33 | return(1); 34 | } 35 | 36 | 37 | /** ------------------------------ STEP I -------------------------- */ 38 | /** 1) Initialisation of mesh and sol structures */ 39 | /* args of InitMesh: 40 | * MMG5_ARG_start: we start to give the args of a variadic func 41 | * MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 42 | * &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh) 43 | * MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 44 | * &mmgSol: pointer toward your MMG5_pSol (that store your metric) */ 45 | 46 | mmgMesh = NULL; 47 | mmgSol = NULL; 48 | MMG2D_Init_mesh(MMG5_ARG_start, 49 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 50 | MMG5_ARG_end); 51 | 52 | /* Set inoffensive hmin and hmax for metric intersection */ 53 | if( !MMG2D_Set_dparameter(mmgMesh,mmgSol,MMG2D_DPARAM_hmin,1.e-6) ) 54 | return EXIT_FAILURE; 55 | if( !MMG2D_Set_dparameter(mmgMesh,mmgSol,MMG2D_DPARAM_hmax,1.e+6) ) 56 | return EXIT_FAILURE; 57 | 58 | 59 | /** ------------------------------ STEP II -------------------------- */ 60 | 61 | /* matrix inversion test */ 62 | if( !MMG5_test_invmat22() ) 63 | return(EXIT_FAILURE); 64 | 65 | /* symmetric matrix eigendecomposition test */ 66 | double m_sym[3] = {2.,1.,2.}; /* Test matrix, non-symmetric storage */ 67 | double lambda_sym[2] = {1.,3.}; /* Exact eigenvalues */ 68 | double vp_sym[2][2] = {{1./sqrt(2.),-1./sqrt(2.)}, 69 | {1./sqrt(2.),1./sqrt(2.)}}; /* Exact eigenvectors */ 70 | if( !MMG5_test_eigenvmatsym2d(mmgMesh,m_sym,lambda_sym,vp_sym) ) 71 | return EXIT_FAILURE; 72 | 73 | /* non-symmetric matrix eigendecomposition test */ 74 | double m_nonsym[4] = { -98., 99., 75 | -198.,199.}; /* Test matrix, non-symmetric storage */ 76 | double lambda_nonsym[2] = {1.,100.}; /* Exact eigenvalues */ 77 | double vp_nonsym[2][2] = {{1./sqrt(2.),1./sqrt(2.)}, 78 | {1./sqrt(5.),2./sqrt(5.)}}; /* Exact right eigenvectors */ 79 | double ivp_nonsym[2][2] = {{2.*sqrt(2.),-sqrt(5.)}, 80 | { -sqrt(2.), sqrt(5.)}}; /* Exact right eigenvectors inverse */ 81 | if( !MMG5_test_eigenvmatnonsym2d(mmgMesh,m_nonsym,lambda_nonsym,vp_nonsym,ivp_nonsym) ) 82 | return EXIT_FAILURE; 83 | 84 | /* simultaneous reduction test */ 85 | double m[3] = { 508., -504, 502.}; /* Test matrix 1 */ 86 | double n[3] = {4020.,-2020.,1020.}; /* Test matrix 2 */ 87 | double dm[2] = { 1., 100. }; /* Exact cobasis projection 1 */ 88 | double dn[2] = {500., 4. }; /* Exact cobasis projection 2 */ 89 | double vp[2][2] = {{1./sqrt(2.),1./sqrt(2.)}, 90 | {1./sqrt(5.),2./sqrt(5.)}}; /* Exact cobasis vectors */ 91 | if( !MMG5_test_simred2d(mmgMesh,m,n,dm,dn,vp) ) 92 | return EXIT_FAILURE; 93 | 94 | /* matrix inverse transformation test */ 95 | if( !MMG5_test_updatemet2d_ani() ) 96 | return EXIT_FAILURE; 97 | 98 | /* metrics intersection test */ 99 | if( !MMG5_test_intersecmet22(mmgMesh) ) 100 | return EXIT_FAILURE; 101 | 102 | /** ------------------------------ STEP III -------------------------- */ 103 | 104 | /** 3) Free the MMG2D structures */ 105 | MMG2D_Free_all(MMG5_ARG_start, 106 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 107 | MMG5_ARG_end); 108 | 109 | return(0); 110 | } 111 | -------------------------------------------------------------------------------- /cmake/testing/libmmg_tests.cmake: -------------------------------------------------------------------------------- 1 | ## ============================================================================= 2 | ## This file is part of the mmg software package for the tetrahedral 3 | ## mesh modification. 4 | ## Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ## 6 | ## mmg is free software: you can redistribute it and/or modify it 7 | ## under the terms of the GNU Lesser General Public License as published 8 | ## by the Free Software Foundation, either version 3 of the License, or 9 | ## (at your option) any later version. 10 | ## 11 | ## mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ## License for more details. 15 | ## 16 | ## You should have received a copy of the GNU Lesser General Public 17 | ## License and of the GNU General Public License along with mmg (in 18 | ## files COPYING.LESSER and COPYING). If not, see 19 | ## . Please read their terms carefully and 20 | ## use this copy of the mmg distribution only if you accept them. 21 | ## ============================================================================= 22 | 23 | ############################################################################### 24 | ##### 25 | ##### Mmg Library Examples 26 | ##### 27 | ############################################################################### 28 | 29 | SET ( MMG_LIB_TESTS 30 | libmmg_example0_a 31 | libmmg_cpp_a 32 | ) 33 | 34 | SET ( MMG_LIB_TESTS_MAIN_PATH 35 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0/main.c 36 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0_cpp/main.cpp 37 | ) 38 | 39 | IF ( LIBMMG_STATIC ) 40 | SET ( lib_name lib${PROJECT_NAME}_a ) 41 | SET ( lib_type "STATIC" ) 42 | ELSEIF ( LIBMMG_SHARED ) 43 | SET ( lib_name lib${PROJECT_NAME}_so ) 44 | SET ( lib_type "SHARED" ) 45 | ELSE () 46 | MESSAGE(WARNING "You must activate the compilation of the static or" 47 | " shared ${PROJECT_NAME} library to compile this tests." ) 48 | ENDIF ( ) 49 | 50 | ##### Fortran Tests 51 | IF (CMAKE_Fortran_COMPILER AND PERL_FOUND) 52 | ENABLE_LANGUAGE (Fortran) 53 | 54 | SET ( MMG_LIB_TESTS ${MMG_LIB_TESTS} 55 | libmmg_fortran_a 56 | ) 57 | 58 | SET ( MMG_LIB_TESTS_MAIN_PATH ${MMG_LIB_TESTS_MAIN_PATH} 59 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0_fortran/main.F90 60 | ) 61 | 62 | ENDIF (CMAKE_Fortran_COMPILER AND PERL_FOUND) 63 | 64 | LIST(LENGTH MMG_LIB_TESTS nbTests_tmp) 65 | MATH(EXPR nbTests "${nbTests_tmp} - 1") 66 | 67 | FOREACH ( test_idx RANGE ${nbTests} ) 68 | LIST ( GET MMG_LIB_TESTS ${test_idx} test_name ) 69 | LIST ( GET MMG_LIB_TESTS_MAIN_PATH ${test_idx} main_path ) 70 | 71 | ADD_LIBRARY_TEST ( ${test_name} ${main_path} copy_mmg_headers ${lib_name} ${lib_type} ) 72 | 73 | ENDFOREACH ( ) 74 | 75 | IF( MMG_CI ) 76 | # Add libmmg tests 77 | SET(LIBMMG_EXEC0_a ${EXECUTABLE_OUTPUT_PATH}/libmmg_example0_a ) 78 | SET(LIBMMG_CPP_a ${EXECUTABLE_OUTPUT_PATH}/libmmg_cpp_a ) 79 | 80 | ADD_TEST(NAME libmmg_example0_a COMMAND ${LIBMMG_EXEC0_a} 81 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0/init 82 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0/cube 83 | "${CTEST_OUTPUT_DIR}/libmmg_Adaptation_0.o") 84 | ADD_TEST(NAME libmmg_cpp_a COMMAND ${LIBMMG_CPP_a} 85 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0_cpp/init 86 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0_cpp/cube 87 | "${CTEST_OUTPUT_DIR}/libmmg_Adaptation_0_cpp.o") 88 | 89 | IF ( CMAKE_Fortran_COMPILER AND PERL_FOUND) 90 | SET(LIBMMG_FORTRAN_a ${EXECUTABLE_OUTPUT_PATH}/libmmg_fortran_a) 91 | ADD_TEST(NAME libmmg_fortran COMMAND ${LIBMMG_FORTRAN_a} 92 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0_fortran/init 93 | ${PROJECT_SOURCE_DIR}/libexamples/mmg/adaptation_example0_fortran/cube 94 | "${CTEST_OUTPUT_DIR}/libmmg_Adaptation_0_Fortran.o" 95 | ) 96 | ENDIF() 97 | 98 | ENDIF( MMG_CI ) 99 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | fixes: 2 | - "mmg/mmg::" 3 | 4 | -------------------------------------------------------------------------------- /doc/doxygen/BUILD_DOXYGEN_DOC.md: -------------------------------------------------------------------------------- 1 | # Mmg doxygen documentation 2 | 3 | ## Online documentation 4 | The Doxygen documentation of the last release of Mmg is available on : https://mmgtools.github.io/ 5 | 6 | ## Build locally your own html documentation 7 | You can build the Mmg documentation using the `make doc` command generated by CMake. 8 | 9 | For CMake begginers you can follow the next steps: 10 | ``` 11 | cd mmg 12 | mkdir build 13 | cd build 14 | cmake .. 15 | make doc 16 | ``` 17 | 18 | By default the Doxygen output is builded by the under the `doc` sub directory of the build directory (so in `build/doc` in the previous example). You can configure the `MMG_DOC_DIR` CMake variable to change the Doxygen output directory. 19 | -------------------------------------------------------------------------------- /doc/doxygen/References.bib: -------------------------------------------------------------------------------- 1 | @article{COUPEZ20112391, 2 | title = {Metric construction by length distribution tensor and edge based error for anisotropic adaptive meshing}, 3 | journal = {Journal of Computational Physics}, 4 | volume = {230}, 5 | number = {7}, 6 | pages = {2391-2405}, 7 | year = {2011}, 8 | issn = {0021-9991}, 9 | doi = {https://doi.org/10.1016/j.jcp.2010.11.041}, 10 | url = {https://www.sciencedirect.com/science/article/pii/S002199911000656X}, 11 | author = {T. Coupez}, 12 | keywords = {Metric, Length distribution tensor, Anisotropic meshing, Interpolation error, Edge error estimate}, 13 | abstract = {Metric tensors play a key role to control the generation of unstructured anisotropic meshes. In practice, the most well established error analysis enables to calculate a metric tensor on an element basis. In this paper, we propose to build a metric field directly at the nodes of the mesh for a direct use in the meshing tools. First, the unit mesh metric is defined and well justified on a node basis, by using the statistical concept of length distribution tensors. Then, the interpolation error analysis is performed on the projected approximate scalar field along the edges. The error estimate is established on each edge whatever the dimension is. It enables to calculate a stretching factor providing a new edge length distribution, its associated tensor and the corresponding metric. The optimal stretching factor field is obtained by solving an optimization problem under the constraint of a fixed number of edges in the mesh. Several examples of interpolation error are proposed as well as preliminary results of anisotropic adaptation for interface and free surface problem using a level set method.} 14 | } 15 | 16 | @inproceedings{vlachos2001curved, 17 | title={Curved PN triangles}, 18 | author={Vlachos, Alex and Peters, J{\"o}rg and Boyd, Chas and Mitchell, Jason L}, 19 | booktitle={Proceedings of the 2001 symposium on Interactive 3D graphics}, 20 | pages={159--166}, 21 | year={2001} 22 | } 23 | 24 | @article{borouchaki1998mesh, 25 | title={Mesh gradation control}, 26 | author={Borouchaki, Houman and Hecht, Frederic and Frey, Pascal J}, 27 | journal={International Journal for Numerical Methods in Engineering}, 28 | volume={43}, 29 | number={6}, 30 | pages={1143--1165}, 31 | year={1998}, 32 | publisher={Wiley Online Library} 33 | } 34 | 35 | @article{dapogny2014three, 36 | title={Three-dimensional adaptive domain remeshing, implicit domain meshing, and applications to free and moving boundary problems}, 37 | author={Dapogny, Charles and Dobrzynski, C{\'e}cile and Frey, Pascal}, 38 | journal={Journal of computational physics}, 39 | volume={262}, 40 | pages={358--378}, 41 | year={2014}, 42 | publisher={Elsevier} 43 | } 44 | -------------------------------------------------------------------------------- /doc/doxygen/custom.css: -------------------------------------------------------------------------------- 1 | /* -*- mode:css; css-indent-offset:2 -*- 2 | * Style customizations for the Doxygen documentation of Mmgtools 3 | * initial version by Mark Potse 03/2024 4 | */ 5 | 6 | 7 | div.contents { 8 | 9 | } 10 | 11 | p { 12 | max-width: 800px; /* limit text line width, for readability */ 13 | } 14 | 15 | -------------------------------------------------------------------------------- /doc/doxygen/logo-Mmg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/doc/doxygen/logo-Mmg.png -------------------------------------------------------------------------------- /doc/man/mmg2d.1.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/doc/man/mmg2d.1.gz -------------------------------------------------------------------------------- /doc/man/mmg3d.1.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/doc/man/mmg3d.1.gz -------------------------------------------------------------------------------- /doc/man/mmgs.1.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/doc/man/mmgs.1.gz -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg library for an adaptation testcase 2 | 3 | ## I/ Implementation 4 | To call the **mmg** library, you must: 5 | 1. build mesh and sol at MMG2D, MMG3D or MMGS format; 6 | 2. call the MMG2D, MMGS or MMG3D library; 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMG<2D/S/3D>_loadMesh** and **MMG<2D/S/3D>_loadSol** functions. 10 | Results are saved using **MMG<2D/S/3D>_saveMesh** and **MMG<2D/S/3D>_saveSol** functions. 11 | 12 | ## II/ Compilation 13 | 1. Build and install the **mmg** shared and static library. We suppose in the following that you have installed the **mmg** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 14 | 2. compile the main.c file specifying: 15 | * the **mmg** include directory with the **-I** option; 16 | * the **mmg** library location with the **-L** option; 17 | * the **mmg** library name with the **-l** option; 18 | * for the static library you must also link the executable with, if used for the **mmg** library compilation, the scotch and scotcherr libraries and with the math library; 19 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 20 | 21 | > Example 1 22 | > Command line to link the application with the **mmg** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 23 | > ```Shell 24 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/ main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg -lscotch -lscotcherr -lm 25 | > ``` 26 | 27 | > Example 2 28 | > Command line to link the application with the **mmg** shared library: 29 | > ```Shell 30 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/ main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg 31 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 32 | > ``` 33 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0/cube.meshb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg/adaptation_example0/cube.meshb -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0/cube.solb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg/adaptation_example0/cube.solb -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0/init.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | 4 | Dimension 2 5 | 6 | 7 | Vertices 8 | 4 9 | 0.000000e+00 0.000000e+00 0 10 | 1.000000e+00 0.000000e+00 0 11 | 1.000000e+00 1.000000e+00 0 12 | 0.000000e+00 1.000000e+00 0 13 | 14 | 15 | Corners 16 | 0 17 | 18 | 19 | RequiredVertices 20 | 0 21 | 22 | 23 | Edges 24 | 4 25 | 1 2 1 26 | 2 3 2 27 | 3 4 3 28 | 4 1 4 29 | 30 | 31 | RequiredEdges 32 | 0 33 | 34 | 35 | Triangles 36 | 2 37 | 1 2 4 1 38 | 2 3 4 1 39 | 40 | 41 | End 42 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0/init.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 2 4 | 5 | SolAtVertices 6 | 4 7 | 1 1 8 | 9 | 0.1 10 | 0.1 11 | 0.1 12 | 0.1 13 | 14 | End 15 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_cpp/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg library for an adaptation testcase in C++ 2 | 3 | ## I/ Implementation 4 | To call the **mmg** library, you must: 5 | 1. build mesh and sol at MMG2D, MMG3D or MMGS format; 6 | 2. call the MMG2D, MMGS or MMG3D library; 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMG<2D/S/3D>_loadMesh** and **MMG<2D/S/3D>_loadSol** functions. 10 | Results are saved using **MMG<2D/S/3D>_saveMesh** and **MMG<2D/S/3D>_saveSol** functions. 11 | 12 | ## II/ Compilation 13 | 1. Build and install the **mmg** shared and static library. We suppose in the following that you have installed the **mmg** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 14 | 2. compile the main.cpp file specifying: 15 | * the **mmg** include directory with the **-I** option; 16 | * the **mmg** library location with the **-L** option; 17 | * the **mmg** library name with the **-l** option; 18 | * for the static library you must also link the executable with, if used for the **mmg** library compilation, the scotch and scotcherr libraries and with the math library; 19 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 20 | 21 | > Example 1 22 | > Command line to link the application with the **mmg** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 23 | > ```Shell 24 | > g++ -I$CMAKE_INSTALL_PREFIX/include/mmg/ main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg -lscotch -lscotcherr -lm 25 | > ``` 26 | 27 | > Example 2 28 | > Command line to link the application with the **mmg** shared library: 29 | > ```Shell 30 | > g++ -I$CMAKE_INSTALL_PREFIX/include/mmg/ main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg 31 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 32 | > ``` 33 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_cpp/cube.meshb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg/adaptation_example0_cpp/cube.meshb -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_cpp/cube.solb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg/adaptation_example0_cpp/cube.solb -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_cpp/init.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | 4 | Dimension 2 5 | 6 | 7 | Vertices 8 | 4 9 | 0.000000e+00 0.000000e+00 0 10 | 1.000000e+00 0.000000e+00 0 11 | 1.000000e+00 1.000000e+00 0 12 | 0.000000e+00 1.000000e+00 0 13 | 14 | 15 | Corners 16 | 0 17 | 18 | 19 | RequiredVertices 20 | 0 21 | 22 | 23 | Edges 24 | 4 25 | 1 2 1 26 | 2 3 2 27 | 3 4 3 28 | 4 1 4 29 | 30 | 31 | RequiredEdges 32 | 0 33 | 34 | 35 | Triangles 36 | 2 37 | 1 2 4 1 38 | 2 3 4 1 39 | 40 | 41 | End 42 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_cpp/init.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 2 4 | 5 | SolAtVertices 6 | 4 7 | 1 1 8 | 9 | 0.1 10 | 0.1 11 | 0.1 12 | 0.1 13 | 14 | End 15 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_fortran/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg library for an adaptation testcase for Fortran users 2 | 3 | ## I/ Implementation 4 | To call the **mmg** library, you must: 5 | 1. build mesh and sol at MMG2D, MMG3D or MMGS format; 6 | 2. call the MMG2D, MMGS or MMG3D library; 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMG<2D/S/3D>_loadMesh** and **MMG<2D/S/3D>_loadSol** functions. 10 | Results are saved using **MMG<2D/S/3D>_saveMesh** and **MMG<2D/S/3D>_saveSol** functions. 11 | 12 | ## II/ Compilation 13 | 1. Build and install the **mmg** shared and static library. We suppose in the following that you have installed the **mmg** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 14 | 2. compile the main.F90 file specifying: 15 | * the **mmg** include directory with the **-I** option; 16 | * the **mmg** library location with the **-L** option; 17 | * the **mmg** library name with the **-l** option; 18 | * for the static library you must also link the executable with, if used for the **mmg** library compilation, the scotch and scotcherr libraries and with the math library; 19 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 20 | 21 | > Example 1 22 | > Command line to link the application with the **mmg** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 23 | > ```Shell 24 | > gfortran -I$CMAKE_INSTALL_PREFIX/include/mmg/ main.F90 -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg -lscotch -lscotcherr -lm 25 | > ``` 26 | 27 | > Example 2 28 | > Command line to link the application with the **mmg** shared library: 29 | > ```Shell 30 | > gfortran -I$CMAKE_INSTALL_PREFIX/include/mmg/ main.F90 -L$CMAKE_INSTALL_PREFIX/lib -lmmg 31 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 32 | > ``` 33 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_fortran/cube.meshb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg/adaptation_example0_fortran/cube.meshb -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_fortran/cube.solb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg/adaptation_example0_fortran/cube.solb -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_fortran/init.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | 4 | Dimension 2 5 | 6 | 7 | Vertices 8 | 4 9 | 0.000000e+00 0.000000e+00 0 10 | 1.000000e+00 0.000000e+00 0 11 | 1.000000e+00 1.000000e+00 0 12 | 0.000000e+00 1.000000e+00 0 13 | 14 | 15 | Corners 16 | 0 17 | 18 | 19 | RequiredVertices 20 | 0 21 | 22 | 23 | Edges 24 | 4 25 | 1 2 1 26 | 2 3 2 27 | 3 4 3 28 | 4 1 4 29 | 30 | 31 | RequiredEdges 32 | 0 33 | 34 | 35 | Triangles 36 | 2 37 | 1 2 4 1 38 | 2 3 4 1 39 | 40 | 41 | End 42 | -------------------------------------------------------------------------------- /libexamples/mmg/adaptation_example0_fortran/init.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 2 4 | 5 | SolAtVertices 6 | 4 7 | 1 1 8 | 9 | 0.1 10 | 0.1 11 | 0.1 12 | 0.1 13 | 14 | End 15 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg2d library 2 | 3 | ## I/ Implementation 4 | To call the **mmg2d** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG2D library; 7 | 3. get the final mesh and sol. 8 | 9 | ### example0_a 10 | We read mesh and solution files using the **MMG2D_loadMesh** and **MMG2D_loadSol** functions. 11 | Results are saved using **MMG2D_saveMesh** and **MMG2D_saveSol** functions. 12 | 13 | ### example0_b 14 | The mesh and solution are hard coded. 15 | They are build in MMG5 format using API functions and are recovered by the same way. 16 | 17 | We show how to recover the mesh/sol. 18 | 19 | ## II/ Compilation 20 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 21 | 2. compile the main.c file specifying: 22 | * the **mmg2d** include directory with the **-I** option; 23 | * the **mmg2d** library location with the **-L** option; 24 | * the **mmg2d** library name with the **-l** option; 25 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 26 | 27 | > Example 1 28 | > Command line to link the application with the **mmg2d** static library 29 | > ```Shell 30 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 31 | > ``` 32 | 33 | > Example 2 34 | > Command line to link the application with the **mmg2d** shared library: 35 | > ```Shell 36 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d 37 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 38 | > ``` 39 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0/example0_a/init.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | 4 | Dimension 2 5 | 6 | 7 | Vertices 8 | 4 9 | 0.000000e+00 0.000000e+00 0 10 | 1.000000e+00 0.000000e+00 0 11 | 1.000000e+00 1.000000e+00 0 12 | 0.000000e+00 1.000000e+00 0 13 | 14 | 15 | Corners 16 | 0 17 | 18 | 19 | RequiredVertices 20 | 0 21 | 22 | 23 | Edges 24 | 4 25 | 1 2 1 26 | 2 3 2 27 | 3 4 3 28 | 4 1 4 29 | 30 | 31 | RequiredEdges 32 | 0 33 | 34 | 35 | Triangles 36 | 2 37 | 1 2 4 1 38 | 2 3 4 1 39 | 40 | 41 | End 42 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0/example0_a/init.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 2 4 | 5 | SolAtVertices 6 | 4 7 | 1 1 8 | 9 | 0.1 10 | 0.1 11 | 0.1 12 | 0.1 13 | 14 | End 15 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0/example0_a/main.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Example of use of the mmg2d library (basic use of mesh adaptation) 3 | * 4 | * \author Cécile Dobrzynski (Inria / IMB, Université de Bordeaux) 5 | * \version 5 6 | * \copyright GNU Lesser General Public License. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | /** Include the mmg2d library hader file */ 19 | // if the header file is in the "include" directory 20 | // #include "libmmg2d.h" 21 | // if the header file is in "include/mmg/mmg2d" 22 | #include "mmg/mmg2d/libmmg2d.h" 23 | 24 | int main(int argc,char *argv[]) { 25 | MMG5_pMesh mmgMesh; 26 | MMG5_pSol mmgSol; 27 | int ier; 28 | char *filename, *fileout; 29 | 30 | fprintf(stdout," -- TEST MMG2DLIB \n"); 31 | 32 | if ( argc != 3 ) { 33 | printf(" Usage: %s filein fileout\n",argv[0]); 34 | return(1); 35 | } 36 | 37 | /* Name and path of the mesh file */ 38 | filename = (char *) calloc(strlen(argv[1]) + 1, sizeof(char)); 39 | if ( filename == NULL ) { 40 | perror(" ## Memory problem: calloc"); 41 | exit(EXIT_FAILURE); 42 | } 43 | strcpy(filename,argv[1]); 44 | 45 | fileout = (char *) calloc(strlen(argv[2]) + 1, sizeof(char)); 46 | if ( fileout == NULL ) { 47 | perror(" ## Memory problem: calloc"); 48 | exit(EXIT_FAILURE); 49 | } 50 | strcpy(fileout,argv[2]); 51 | 52 | /** ------------------------------ STEP I -------------------------- */ 53 | /** 1) Initialisation of mesh and sol structures */ 54 | /* args of InitMesh: 55 | * MMG5_ARG_start: we start to give the args of a variadic func 56 | * MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 57 | * &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh) 58 | * MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 59 | * &mmgSol: pointer toward your MMG5_pSol (that store your metric) */ 60 | 61 | mmgMesh = NULL; 62 | mmgSol = NULL; 63 | MMG2D_Init_mesh(MMG5_ARG_start, 64 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 65 | MMG5_ARG_end); 66 | 67 | /** 2) Build mesh in MMG5 format */ 68 | /** Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b) 69 | file formatted or manually set your mesh using the MMG2D_Set* functions */ 70 | 71 | /** with MMG2D_loadMesh function */ 72 | if ( MMG2D_loadMesh(mmgMesh,filename) != 1 ) exit(EXIT_FAILURE); 73 | 74 | /** 3) Build sol in MMG5 format */ 75 | /** Two solutions: just use the MMG2D_loadSol function that will read a .sol(b) 76 | file formatted or manually set your sol using the MMG2D_Set* functions */ 77 | 78 | /** With MMG2D_loadSol function */ 79 | if ( MMG2D_loadSol(mmgMesh,mmgSol,filename) != 1 ) 80 | exit(EXIT_FAILURE); 81 | 82 | /** 4) (not mandatory): check if the number of given entities match with mesh size */ 83 | if ( MMG2D_Chk_meshData(mmgMesh,mmgSol) != 1 ) exit(EXIT_FAILURE); 84 | 85 | /*save init mesh*/ 86 | if ( MMG2D_saveMesh(mmgMesh,fileout) != 1 ) 87 | exit(EXIT_FAILURE); 88 | if ( MMG2D_saveSol(mmgMesh,mmgSol,fileout) != 1 ) 89 | exit(EXIT_FAILURE); 90 | 91 | /** ------------------------------ STEP II -------------------------- */ 92 | ier = MMG2D_mmg2dlib(mmgMesh,mmgSol); 93 | 94 | if ( ier == MMG5_STRONGFAILURE ) { 95 | fprintf(stdout,"BAD ENDING OF MMG2DLIB: UNABLE TO SAVE MESH\n"); 96 | return(ier); 97 | } else if ( ier == MMG5_LOWFAILURE ) 98 | fprintf(stdout,"BAD ENDING OF MMG2DLIB\n"); 99 | 100 | /** ------------------------------ STEP III -------------------------- */ 101 | /*save result*/ 102 | if ( MMG2D_saveMesh(mmgMesh,fileout) != 1 ) 103 | exit(EXIT_FAILURE); 104 | 105 | /*save metric*/ 106 | if ( MMG2D_saveSol(mmgMesh,mmgSol,fileout) != 1 ) 107 | exit(EXIT_FAILURE); 108 | 109 | /** 3) Free the MMG2D structures */ 110 | MMG2D_Free_all(MMG5_ARG_start, 111 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 112 | MMG5_ARG_end); 113 | 114 | free(fileout); 115 | fileout = NULL; 116 | 117 | return(0); 118 | } 119 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0_fortran/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg2d library for a Fortran call 2 | 3 | ## I/ Implementation 4 | To call the **mmg3d** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG5 library; 7 | 3. get the final mesh and sol. 8 | 9 | ### example0_a 10 | We read mesh and solution files using the **MMG2D_loadMesh** and **MMG2D_loadSol** functions. 11 | Results are saved using **MMG2D_saveMesh** and **MMG2D_saveSol** functions. 12 | 13 | ### example0_b 14 | The mesh and solution are hard coded. 15 | They are build in MMG5 format using API functions and are recovered by the same way. 16 | We show how to recover the mesh/sol. 17 | 18 | ## II/ Compilation 19 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 20 | 2. compile the main.F90 file specifying: 21 | * the **mmg2d** include directory with the **-I** option; 22 | * the **mmg2d** library location with the **-L** option; 23 | * the **mmg2d** library name with the **-l** option; 24 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 25 | 26 | > Example 1 27 | > Command line to link the application with the **mmg2d** static library 28 | > ```Shell 29 | > gfortran -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.F90 -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 30 | > ``` 31 | 32 | > Example 2 33 | > Command line to link the application with the **mmg2d** shared library: 34 | > ```Shell 35 | > gfortran -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.F90 -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d 36 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 37 | > ``` 38 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0_fortran/example0_a/init.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | 4 | Dimension 2 5 | 6 | 7 | Vertices 8 | 4 9 | 0.000000e+00 0.000000e+00 0 10 | 1.000000e+00 0.000000e+00 0 11 | 1.000000e+00 1.000000e+00 0 12 | 0.000000e+00 1.000000e+00 0 13 | 14 | 15 | Corners 16 | 0 17 | 18 | 19 | RequiredVertices 20 | 0 21 | 22 | 23 | Edges 24 | 4 25 | 1 2 1 26 | 2 3 2 27 | 3 4 3 28 | 4 1 4 29 | 30 | 31 | RequiredEdges 32 | 0 33 | 34 | 35 | Triangles 36 | 2 37 | 1 2 4 1 38 | 2 3 4 1 39 | 40 | 41 | End 42 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0_fortran/example0_a/init.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 2 4 | 5 | SolAtVertices 6 | 4 7 | 1 1 8 | 9 | 0.1 10 | 0.1 11 | 0.1 12 | 0.1 13 | 14 | End 15 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example0_fortran/example0_a/main.F90: -------------------------------------------------------------------------------- 1 | !> @author 2 | !> Cecile Dobrzynski, Charles Dapogny, Pascal Frey and Algiane Froehly 3 | !> @brief 4 | !> Example for using mmg2dlib (basic use) 5 | 6 | PROGRAM main 7 | 8 | IMPLICIT NONE 9 | 10 | !> Include here the mmg3d library hader file 11 | ! if the header file is in the "include" directory 12 | ! #include "libmmg2df.h" 13 | 14 | ! if the header file is in "include/mmg/mmg2d" 15 | #include "mmg/mmg2d/libmmg2df.h" 16 | 17 | MMG5_DATA_PTR_T :: mmgMesh 18 | MMG5_DATA_PTR_T :: mmgSol 19 | INTEGER :: ier,argc 20 | CHARACTER(len=300) :: exec_name,filename,fileout 21 | 22 | PRINT*," -- TEST MMG2DLIB" 23 | 24 | argc = COMMAND_ARGUMENT_COUNT(); 25 | CALL get_command_argument(0, exec_name) 26 | 27 | IF ( argc /=2 ) THEN 28 | PRINT*," Usage: ",TRIM(ADJUSTL(exec_name))," input_file_name output_file_name" 29 | CALL EXIT(1); 30 | ENDIF 31 | 32 | ! Name and path of the mesh file 33 | CALL get_command_argument(1, filename) 34 | CALL get_command_argument(2, fileout) 35 | 36 | 37 | !> ------------------------------ STEP I -------------------------- 38 | !! 1) Initialisation of mesh and sol structures 39 | !! args of InitMesh: 40 | !! MMG5_ARG_start: we start to give the args of a variadic func 41 | !! MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 42 | !! mmgMesh: your MMG5_pMesh (that store your mesh) 43 | !! MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 44 | !! mmgSol: your MMG5_pSol (that store your metric) */ 45 | 46 | mmgMesh = 0 47 | mmgSol = 0 48 | 49 | CALL MMG2D_Init_mesh(MMG5_ARG_start, & 50 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgSol, & 51 | MMG5_ARG_end) 52 | 53 | !> 2) Build mesh in MMG5 format 54 | !! Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b) 55 | !! file formatted or manually set your mesh using the MMG2D_Set* functions 56 | 57 | !> with MMG2D_loadMesh function 58 | CALL MMG2D_loadMesh(mmgMesh,TRIM(ADJUSTL(filename)),& 59 | LEN(TRIM(ADJUSTL(filename))),ier) 60 | IF ( ier /= 1 ) CALL EXIT(102) 61 | 62 | !> 3) Build sol in MMG5 format 63 | !! Two solutions: just use the MMG2D_loadMet function that will read a .sol(b) 64 | !! file formatted or manually set your sol using the MMG2D_Set* functions 65 | 66 | !> With MMG2D_loadSol function 67 | CALL MMG2D_loadSol(mmgMesh,mmgSol,TRIM(ADJUSTL(filename)),& 68 | LEN(TRIM(ADJUSTL(filename))),ier) 69 | IF ( ier /= 1 ) THEN 70 | CALL EXIT(104) 71 | ENDIF 72 | 73 | !> 4) (not mandatory): check if the number of given entities match with mesh size 74 | CALL MMG2D_Chk_meshData(mmgMesh,mmgSol,ier) 75 | IF ( ier /= 1 ) CALL EXIT(107) 76 | 77 | !> ------------------------------ STEP II -------------------------- 78 | !! remesh function 79 | ! NULLIFY(va) 80 | CALL MMG2D_mmg2dlib(mmgMesh,mmgSol,ier) 81 | IF ( ier == MMG5_STRONGFAILURE ) THEN 82 | PRINT*,"BAD ENDING OF MMG2DLIB: UNABLE TO SAVE MESH" 83 | STOP MMG5_STRONGFAILURE 84 | ELSE IF ( ier == MMG5_LOWFAILURE ) THEN 85 | PRINT*,"BAD ENDING OF MMG2DLIB" 86 | ELSE 87 | PRINT*,"MMG2DLIB SUCCEED" 88 | ENDIF 89 | 90 | !> ------------------------------ STEP III -------------------------- 91 | !! get results 92 | !! Two solutions: just use the MMG2D_saveMesh/MMG2D_saveSol functions 93 | !! that will write .mesh(b)/.sol formatted files or manually get your mesh/sol 94 | !! using the MMG2D_getMesh/MMG2D_getSol functions 95 | 96 | !> 1) Automatically save the mesh 97 | CALL MMG2D_saveMesh(mmgMesh,TRIM(ADJUSTL(fileout)),LEN(TRIM(ADJUSTL(fileout))),ier) 98 | IF ( ier /= 1 ) CALL EXIT(106) 99 | 100 | !> 2) Automatically save the solution 101 | CALL MMG2D_saveSol(mmgMesh,mmgSol,TRIM(ADJUSTL(fileout)),LEN(TRIM(ADJUSTL(fileout))),ier) 102 | IF ( ier /= 1 ) CALL EXIT(107) 103 | 104 | !> 3) Free the MMG2D5 structures 105 | CALL MMG2D_Free_all(MMG5_ARG_start, & 106 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgSol, & 107 | MMG5_ARG_end) 108 | 109 | END PROGRAM main 110 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example1/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg2d library to perform mesh adaptation 2 | 3 | ## I/ Implementation 4 | To call the **mmg2d** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG2D library; 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMG2D_loadMesh** and **MMG2D_loadSol** functions. 10 | Results are saved using **MMG2D_saveMesh** and **MMG2D_saveSol** functions. 11 | 12 | 13 | ## II/ Compilation 14 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 15 | 2. compile the main.c file specifying: 16 | * the **mmg2d** include directory with the **-I** option; 17 | * the **mmg2d** library location with the **-L** option; 18 | * the **mmg2d** library name with the **-l** option; 19 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 20 | 21 | > Example 1 22 | > Command line to link the application with the **mmg2d** static library 23 | > ```Shell 24 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 25 | > ``` 26 | 27 | > Example 2 28 | > Command line to link the application with the **mmg2d** shared library: 29 | > ```Shell 30 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d 31 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 32 | > ``` 33 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example1/main.c: -------------------------------------------------------------------------------- 1 | /*Authors Cécile Dobrzynski 2 | 3 | Example for using mmg2dlib 4 | 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /** Include the mmg2d library hader file */ 16 | // if the header file is in the "include" directory 17 | // #include "libmmg2d.h" 18 | // if the header file is in "include/mmg/mmg2d" 19 | #include "mmg/mmg2d/libmmg2d.h" 20 | 21 | int main(int argc,char *argv[]) { 22 | MMG5_pMesh mmgMesh; 23 | MMG5_pSol mmgSol; 24 | char *filename, *outname; 25 | MMG5_int k,np; 26 | int ier; 27 | 28 | fprintf(stdout," -- TEST MMG2DLIB \n"); 29 | 30 | if ( argc != 3 ) { 31 | printf(" Usage: %s filein fileout\n",argv[0]); 32 | return(1); 33 | } 34 | 35 | /* Name and path of the mesh file */ 36 | filename = (char *) calloc(strlen(argv[1]) + 1, sizeof(char)); 37 | if ( filename == NULL ) { 38 | perror(" ## Memory problem: calloc"); 39 | exit(EXIT_FAILURE); 40 | } 41 | strcpy(filename,argv[1]); 42 | 43 | outname = (char *) calloc(strlen(argv[2]) + 1, sizeof(char)); 44 | if ( outname == NULL ) { 45 | perror(" ## Memory problem: calloc"); 46 | exit(EXIT_FAILURE); 47 | } 48 | strcpy(outname,argv[2]); 49 | 50 | /** ------------------------------ STEP I -------------------------- */ 51 | /** 1) Initialisation of mesh and sol structures */ 52 | /* args of InitMesh: 53 | * MMG5_ARG_start: we start to give the args of a variadic func 54 | * MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 55 | * &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh) 56 | * MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 57 | * &mmgSol: pointer toward your MMG5_pSol (that store your metric) */ 58 | 59 | mmgMesh = NULL; 60 | mmgSol = NULL; 61 | MMG2D_Init_mesh(MMG5_ARG_start, 62 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 63 | MMG5_ARG_end); 64 | 65 | /** 2) Build mesh in MMG5 format */ 66 | /** Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b) 67 | file formatted or manually set your mesh using the MMG2D_Set* functions */ 68 | 69 | /** with MMG2D_loadMesh function */ 70 | if ( MMG2D_loadMesh(mmgMesh,filename) != 1 ) exit(EXIT_FAILURE); 71 | 72 | /** 3) Build sol in MMG5 format */ 73 | /** Two solutions: just use the MMG2D_loadMet function that will read a .sol(b) 74 | file formatted or manually set your sol using the MMG2D_Set* functions */ 75 | 76 | /** Manually set of the sol */ 77 | /** a) Get np the number of vertex */ 78 | if ( MMG2D_Get_meshSize(mmgMesh,&np,NULL,NULL,NULL) != 1 ) 79 | exit(EXIT_FAILURE); 80 | 81 | /** b) give info for the sol structure: sol applied on vertex entities, 82 | number of vertices=np, the sol is scalar*/ 83 | if ( MMG2D_Set_solSize(mmgMesh,mmgSol,MMG5_Vertex,np,MMG5_Scalar) != 1 ) 84 | exit(EXIT_FAILURE); 85 | 86 | /** c) give solutions values and positions */ 87 | for(k=1 ; k<=np ; k++) { 88 | if ( MMG2D_Set_scalarSol(mmgSol,0.01,k) != 1 ) exit(EXIT_FAILURE); 89 | } 90 | 91 | /** 4) (not mandatory): check if the number of given entities match with mesh size */ 92 | if ( MMG2D_Chk_meshData(mmgMesh,mmgSol) != 1 ) exit(EXIT_FAILURE); 93 | 94 | ier = MMG2D_mmg2dlib(mmgMesh,mmgSol); 95 | 96 | if ( ier == MMG5_STRONGFAILURE ) { 97 | fprintf(stdout,"BAD ENDING OF MMG2DLIB: UNABLE TO SAVE MESH\n"); 98 | return(ier); 99 | } else if ( ier == MMG5_LOWFAILURE ) 100 | fprintf(stdout,"BAD ENDING OF MMG2DLIB\n"); 101 | 102 | /*save result*/ 103 | if ( MMG2D_saveMesh(mmgMesh,outname) != 1 ) exit(EXIT_FAILURE); 104 | 105 | /*save metric*/ 106 | if ( MMG2D_saveSol(mmgMesh,mmgSol,outname) != 1 ) exit(EXIT_FAILURE); 107 | 108 | /** 5) Free the MMG3D5 structures */ 109 | MMG2D_Free_all(MMG5_ARG_start, 110 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 111 | MMG5_ARG_end); 112 | 113 | free(filename); 114 | filename = NULL; 115 | 116 | free(outname); 117 | outname = NULL; 118 | 119 | return(0); 120 | } 121 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example2/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg2d library to perform mesh adaptation with 2 calls of the library and deletion of the metric between the call. 2 | 3 | ## I/ Implementation 4 | This example: 5 | 1. build mesh and metric at MMG5 format; 6 | 2. call the MMG2D library; 7 | 3. get the mesh and metric and save its; 8 | 4. remove the metric to not reuse it; 9 | 5. call again the MMG2D library; 10 | 3. get the final mesh. 11 | 12 | We read mesh and solution files using the **MMG2D_loadMesh** and **MMG2D_loadSol** functions. 13 | Results are saved using **MMG2D_saveMesh** and **MMG2D_saveSol** functions. 14 | 15 | 16 | ## II/ Compilation 17 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 18 | 2. compile the main.c file specifying: 19 | * the **mmg2d** include directory with the **-I** option; 20 | * the **mmg2d** library location with the **-L** option; 21 | * the **mmg2d** library name with the **-l** option; 22 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 23 | 24 | > Example 1 25 | > Command line to link the application with the **mmg2d** static library 26 | > ```Shell 27 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 28 | > ``` 29 | 30 | > Example 2 31 | > Command line to link the application with the **mmg2d** shared library: 32 | > ```Shell 33 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d 34 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 35 | > ``` 36 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example2/main.c: -------------------------------------------------------------------------------- 1 | /*Authors Cécile Dobrzynski 2 | 3 | Example for using mmg2dlib 4 | 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /** Include the mmg2d library hader file */ 16 | // if the header file is in the "include" directory 17 | // #include "libmmg2d.h" 18 | // if the header file is in "include/mmg/mmg2d" 19 | #include "mmg/mmg2d/libmmg2d.h" 20 | 21 | int main(int argc,char *argv[]) { 22 | MMG5_pMesh mmgMesh; 23 | MMG5_pSol mmgSol; 24 | char *filename, *outname, *outname2; 25 | MMG5_int k,np; 26 | int ier; 27 | 28 | fprintf(stdout," -- TEST MMG2DLIB \n"); 29 | 30 | if ( argc != 4 ) { 31 | printf(" Usage: %s filein fileout1 fileout2\n",argv[0]); 32 | return(1); 33 | } 34 | 35 | /* Name and path of the mesh file */ 36 | filename = (char *) calloc(strlen(argv[1]) + 1, sizeof(char)); 37 | if ( filename == NULL ) { 38 | perror(" ## Memory problem: calloc"); 39 | exit(EXIT_FAILURE); 40 | } 41 | strcpy(filename,argv[1]); 42 | 43 | outname = (char *) calloc(strlen(argv[2]) + 1, sizeof(char)); 44 | if ( outname == NULL ) { 45 | perror(" ## Memory problem: calloc"); 46 | exit(EXIT_FAILURE); 47 | } 48 | strcpy(outname,argv[2]); 49 | 50 | outname2 = (char *) calloc(strlen(argv[3]) + 1, sizeof(char)); 51 | if ( outname2 == NULL ) { 52 | perror(" ## Memory problem: calloc"); 53 | exit(EXIT_FAILURE); 54 | } 55 | strcpy(outname2,argv[3]); 56 | 57 | /** ------------------------------ STEP I -------------------------- */ 58 | /** 1) Initialisation of mesh and sol structures */ 59 | /* args of InitMesh: 60 | * MMG5_ARG_start: we start to give the args of a variadic func 61 | * MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 62 | * &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh) 63 | * MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 64 | * &mmgSol: pointer toward your MMG5_pSol (that store your metric) */ 65 | 66 | mmgMesh = NULL; 67 | mmgSol = NULL; 68 | MMG2D_Init_mesh(MMG5_ARG_start, 69 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 70 | MMG5_ARG_end); 71 | 72 | /** 2) Build mesh in MMG5 format */ 73 | /** Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b) 74 | file formatted or manually set your mesh using the MMG2D_Set* functions */ 75 | 76 | /** with MMG2D_loadMesh function */ 77 | if ( MMG2D_loadMesh(mmgMesh,filename) != 1 ) { 78 | printf("unable to load mesh"); 79 | exit(EXIT_FAILURE); 80 | } 81 | 82 | /** 3) Build sol in MMG5 format */ 83 | /** Two solutions: just use the MMG2D_loadMet function that will read a .sol(b) 84 | file formatted or manually set your sol using the MMG2D_Set* functions */ 85 | 86 | /** Manually set of the sol */ 87 | /** a) Get np the number of vertex */ 88 | if ( MMG2D_Get_meshSize(mmgMesh,&np,NULL,NULL,NULL) != 1 ) 89 | exit(EXIT_FAILURE); 90 | 91 | /** b) give info for the sol structure: sol applied on vertex entities, 92 | number of vertices=np, the sol is scalar*/ 93 | if ( MMG2D_Set_solSize(mmgMesh,mmgSol,MMG5_Vertex,np,MMG5_Scalar) != 1 ) 94 | exit(EXIT_FAILURE); 95 | 96 | /** c) give solutions values and positions */ 97 | for(k=1 ; k<=np ; k++) { 98 | if ( MMG2D_Set_scalarSol(mmgSol,0.01,k) != 1 ) exit(EXIT_FAILURE); 99 | } 100 | 101 | /** 4) (not mandatory): check if the number of given entities match with mesh size */ 102 | if ( MMG2D_Chk_meshData(mmgMesh,mmgSol) != 1 ) exit(EXIT_FAILURE); 103 | 104 | ier = MMG2D_mmg2dlib(mmgMesh,mmgSol); 105 | 106 | if ( ier == MMG5_STRONGFAILURE ) { 107 | fprintf(stdout,"BAD ENDING OF MMG2DLIB: UNABLE TO SAVE MESH\n"); 108 | return(ier); 109 | } else if ( ier == MMG5_LOWFAILURE ) 110 | fprintf(stdout,"BAD ENDING OF MMG2DLIB\n"); 111 | 112 | /*save result*/ 113 | if ( MMG2D_saveMesh(mmgMesh,outname) != 1 ) exit(EXIT_FAILURE); 114 | 115 | /*save metric*/ 116 | if ( MMG2D_saveSol(mmgMesh,mmgSol,outname) != 1 ) exit(EXIT_FAILURE); 117 | 118 | /* Reset the metric to call mmg2dlib a second time without metric */ 119 | MMG2D_Free_solutions(mmgMesh,mmgSol); 120 | 121 | ier = MMG2D_mmg2dlib(mmgMesh,mmgSol); 122 | if ( ier == MMG5_STRONGFAILURE ) { 123 | fprintf(stdout,"BAD ENDING OF MMG2DLIB: UNABLE TO SAVE MESH\n"); 124 | return(ier); 125 | } else if ( ier == MMG5_LOWFAILURE ) 126 | fprintf(stdout,"BAD ENDING OF MMG2DLIB\n"); 127 | 128 | /*save result*/ 129 | if ( MMG2D_saveMesh(mmgMesh,outname2) != 1 ) exit(EXIT_FAILURE); 130 | 131 | /** 5) Free the MMG3D5 structures */ 132 | MMG2D_Free_all(MMG5_ARG_start, 133 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 134 | MMG5_ARG_end); 135 | 136 | free(filename); 137 | filename = NULL; 138 | 139 | free(outname); 140 | outname = NULL; 141 | 142 | free(outname2); 143 | outname2 = NULL; 144 | 145 | return 0; 146 | } 147 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example3/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg2d library 2 | 3 | ## Adaptation example 3 4 | No mesh or sol file necessary, only compilation of main.c. 5 | 6 | ## Compilation 7 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 8 | 2. compile the main.c file specifying: 9 | * the **mmg2d** include directory with the **-I** option; 10 | * the **mmg2d** library location with the **-L** option; 11 | * the **mmg2d** library name with the **-l** option; 12 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 13 | 14 | > Command line to link the application with the **mmg2d** static library 15 | > ```Shell 16 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 17 | > ``` 18 | 19 | > Command line to link the application with the **mmg2d** shared library: 20 | > ```Shell 21 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 22 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 23 | > ``` 24 | -------------------------------------------------------------------------------- /libexamples/mmg2d/adaptation_example3/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() { 7 | MMG5_pMesh mesh2 = NULL; 8 | MMG5_pSol met2 = NULL; 9 | int ier = 0; 10 | MMG2D_Init_mesh(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh2, MMG5_ARG_ppMet, &met2, MMG5_ARG_end); 11 | MMG2D_Set_iparameter(mesh2, met2, MMG2D_IPARAM_verbose, 10); 12 | 13 | // 4 vertices, no tris, no quads, no edges so far 14 | MMG2D_Set_meshSize(mesh2, 4, 0, 0, 0); 15 | 16 | // a rectangle [0, 2 * M_PI] x [-M_PI / 2, M_PI / 2] for spherical coordinates in usual lon/lat way 17 | double v[8] = {0, -M_PI/2, 2 * M_PI, -M_PI/2, 2 * M_PI, M_PI/2, 0, M_PI/2}; 18 | MMG2D_Set_vertices(mesh2, v, NULL); 19 | 20 | MMG2D_Set_dparameter(mesh2, met2, MMG2D_DPARAM_hsiz, 0.01); 21 | 22 | // generate a regular fine mesh of the square in meshing mode 23 | ier = MMG2D_mmg2dmesh(mesh2, met2); 24 | if (ier) { 25 | fprintf(stderr, "error %i during meshing.\n", ier); 26 | exit(1); 27 | } 28 | 29 | // save the "computational geometry" mesh and the metric set by MMG2D_mmg2dmesh 30 | // For Medit users 31 | MMG2D_saveMesh(mesh2, "cg.mesh"); 32 | MMG2D_saveSol(mesh2, met2, "cg.sol"); 33 | // For Gmsh users 34 | MMG2D_saveMshMesh(mesh2, NULL, "cg.msh"); 35 | 36 | MMG2D_Free_solutions(mesh2,met2); 37 | 38 | // remesh with anisotropic metric 39 | int np, nt, nquad, na; 40 | MMG2D_Get_meshSize(mesh2, &np, &nt, &nquad, &na); 41 | double* verts = malloc(2 * np * sizeof(double)); 42 | MMG2D_Get_vertices(mesh2, verts, NULL, NULL, NULL); 43 | MMG2D_Set_solSize(mesh2, met2, MMG5_Vertex, np, MMG5_Tensor); 44 | for (int i = 0; i < np; i++) { 45 | 46 | // latitude 47 | double y = verts[2 * i + 1]; 48 | // metric on the sphere, see standard textbooks on elementary differential geometry 49 | // Gaussian fundamental quantities 50 | double E = cos(y) * cos(y); 51 | double F = 0.0; 52 | double G = 1.0; 53 | 54 | // The symetric metric tensor (E F \\ F G) may be diagonalized in the basis of its 55 | // eigenvectors. The eigenvalue \lambda_i associated to the eigenvector e_i prescribes a 56 | // length l_i = 1/\sqrt(\lambda_i) in the direction e_i. This formula allows to compute 57 | // a size factor to have sufficiently small edges on the surface of the sphere of radius 1. 58 | // 59 | // For a detailed explanation, see: 60 | // https://forum.mmgtools.org/t/how-to-scale-the-metric-for-anisotropic-meshing-in-mmg2d-example-provided/441/2?u=algiane 61 | double factor = 100.0; 62 | 63 | // we add a small amount to the 1-1-entry to make the metric non-singular everywhere 64 | const double eps = 1.e-1; 65 | MMG2D_Set_tensorSol(met2, factor * E + eps, factor * F, factor * G, i+1); 66 | } 67 | 68 | // disable hsiz because it is incompatible with an anisotropic metric 69 | MMG2D_Set_dparameter(mesh2, met2, MMG2D_DPARAM_hsiz, -1); 70 | 71 | // set gradation to a not too restrictive value 72 | MMG2D_Set_dparameter(mesh2, met2, MMG2D_DPARAM_hgrad, 1.5); 73 | 74 | // save the "computational geometry" mesh and the setted metric 75 | // For Medit users 76 | MMG2D_saveMesh(mesh2, "cg-with-met.mesh"); 77 | MMG2D_saveSol(mesh2, met2, "cg-with-met.sol"); 78 | // For Gmsh users 79 | MMG2D_saveMshMesh(mesh2, met2, "cg-with-met.msh"); 80 | 81 | // do it, remesh! 82 | ier = MMG2D_mmg2dlib(mesh2, met2); 83 | 84 | if (ier != 0) { 85 | fprintf(stderr, "error %i during remeshing.\n", ier); 86 | exit(1); 87 | } 88 | 89 | // Save at Gmsh file format 90 | MMG2D_saveMshMesh(mesh2, NULL, "out2.msh"); 91 | 92 | // Save at Medit one 93 | MMG2D_saveMesh(mesh2, "out2.mesh"); 94 | MMG2D_saveSol(mesh2,met2, "out2.sol"); 95 | 96 | // map to 3d and save as Medit file 97 | MMG2D_Get_meshSize(mesh2, &np, &nt, &nquad, &na); 98 | verts = realloc(verts, 2 * np * sizeof(double)); 99 | int* tris = malloc(3 * nt * sizeof(int)); 100 | MMG2D_Get_vertices(mesh2, verts, NULL, NULL, NULL); 101 | MMG2D_Get_triangles(mesh2, tris, NULL, NULL); 102 | 103 | printf("\n\n -- Save the final mesh 'sphere-end.mesh' at Medit file format.\n"); 104 | 105 | FILE *fp = fopen("sphere-end.mesh", "w+"); 106 | 107 | fprintf(fp, "MeshVersionFormatted 2\n\n Dimension 3\n\n Vertices %d\n\n", np); 108 | for (int i = 0; i < np; i++) { 109 | double x = verts[2 * i]; 110 | double y = verts[2 * i + 1]; 111 | /* Parametrization of a sphere of radius 1 from the longitude (x) and 112 | * latitude (y) */ 113 | double newx = cos(x) * cos(y); 114 | double newy = sin(x) * cos(y); 115 | double newz = sin(y); 116 | fprintf(fp, "%f %f %f 0\n", newx, newy, newz); 117 | } 118 | fprintf(fp, "Triangles %d\n", nt); 119 | 120 | for (int i = 0; i < nt; i++) 121 | fprintf(fp, "%i %i %i 0\n", tris[3 * i], tris[3 * i +1], tris[3 * i + 2]); 122 | 123 | fprintf(fp, "End\n"); 124 | fclose(fp); 125 | 126 | free(verts); 127 | free(tris); 128 | MMG2D_Free_all(MMG5_ARG_start, MMG5_ARG_ppMesh, &mesh2, MMG5_ARG_ppMet, &met2, MMG5_ARG_end); 129 | 130 | return 0; 131 | } 132 | -------------------------------------------------------------------------------- /libexamples/mmg2d/io_multisols_example0/README.md: -------------------------------------------------------------------------------- 1 | # Input and output for multiple solutions (we do not call any mmg library here) 2 | 3 | ## I/ Implementation 4 | 1. Read a mesh and a solution file with multiple solutions at MMG5 format 5 | (using the **MMG2D_loadMesh** and **MMG2D_loadAllSols** functions). 6 | 2. Use the Mmg setters to set this solutions in another solution structure. 7 | 3. Use the Mmg getters to get the solutions in another new solution structure. 8 | 4. Save this last solution structure and the multiple solutions stored using 9 | the **MMG2D_saveAllSols** function. 10 | 11 | ## II/ Compilation 12 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 13 | 2. compile the main.c file specifying: 14 | * the **mmg2d** include directory with the **-I** option; 15 | * the **mmg2d** library location with the **-L** option; 16 | * the **mmg2d** library name with the **-l** option; 17 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 18 | 19 | > Example 1 20 | > Command line to link the application with the **mmg2d** static library 21 | > ```Shell 22 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 23 | > ``` 24 | 25 | > Example 2 26 | > Command line to link the application with the **mmg2d** shared library: 27 | > ```Shell 28 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d 29 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 30 | > ``` 31 | -------------------------------------------------------------------------------- /libexamples/mmg2d/io_multisols_example0/visu.F90: -------------------------------------------------------------------------------- 1 | !> @author Cecile Dobrzynski, Charles Dapogny, Pascal Frey and Algiane Froehly 2 | !> @brief Example of input output for the mmg2d library for multiple solutions 3 | !> at mesh vertices 4 | 5 | PROGRAM main 6 | 7 | IMPLICIT NONE 8 | 9 | !> Include here the mmg3d library hader file 10 | ! if the header file is in the "include" directory 11 | ! #include "libmmg2df.h" 12 | 13 | ! if the header file is in "include/mmg/mmg2d" 14 | #include "mmg/mmg2d/libmmg2df.h" 15 | 16 | MMG5_DATA_PTR_T :: mesh 17 | MMG5_DATA_PTR_T :: sol,mmgMet 18 | INTEGER :: ier,argc,i,j,opt 19 | 20 | CHARACTER(len=300) :: exec_name,filename,fileout 21 | 22 | PRINT*," -- 2D MESH GENERATION FOR VISUALIZATION" 23 | 24 | argc = COMMAND_ARGUMENT_COUNT(); 25 | CALL get_command_argument(0, exec_name) 26 | 27 | 28 | IF ( argc /= 2 ) THEN 29 | PRINT*," Usage: ",TRIM(ADJUSTL(exec_name)),& 30 | " input_file_name output_file_name" & 31 | " Generation of a triangular mesh for solution vizualisation (at VTK & 32 | & file format) from a Medit mesh file containing only points and the & 33 | & associated solution file." 34 | CALL EXIT(1); 35 | ENDIF 36 | 37 | ! Name and path of the mesh file 38 | CALL get_command_argument(1, filename) 39 | CALL get_command_argument(2, fileout) 40 | 41 | !!> ------------------------------ STEP I -------------------------- 42 | !! 1) Initialisation of mesh and sol structures */ 43 | !! args of InitMesh: 44 | !! MMG5_ARG_start: we start to give the args of a variadic func 45 | !! MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 46 | !! &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh) 47 | !! MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 48 | !! &mmgSol: pointer toward your MMG5_pSol (that store your metric) 49 | 50 | mesh = 0 51 | sol = 0 52 | mmgMet = 0 53 | 54 | CALL MMG2D_Init_mesh(MMG5_ARG_start, & 55 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgMet, & 56 | MMG5_ARG_ppMet,sol, & 57 | MMG5_ARG_end); 58 | 59 | 60 | !!> 2) Build initial mesh and solutions in MMG5 format 61 | !! Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b) 62 | !! file formatted or manually set your mesh using the MMG2D_Set* functions 63 | 64 | !!> Automatic loading of the mesh and multiple solutions 65 | CALL MMG2D_loadMesh(mesh,TRIM(ADJUSTL(filename)),& 66 | LEN(TRIM(ADJUSTL(filename))),ier) 67 | IF ( ier /= 1 ) CALL EXIT(102) 68 | 69 | CALL MMG2D_loadSol(mesh,sol,TRIM(ADJUSTL(filename)),& 70 | LEN(TRIM(ADJUSTL(filename))),ier) 71 | IF ( ier /= 1 ) CALL EXIT(103) 72 | 73 | !!> ------------------------------ STEP II --------------------------- 74 | !! Mesh generation 75 | CALL MMG2D_Set_iparameter(mesh,mmgMet,MMG2D_IPARAM_NOINSERT,1,ier); 76 | IF ( ier /= 1 ) CALL EXIT(104) 77 | 78 | CALL MMG2D_Set_iparameter(mesh,mmgMet,MMG2D_IPARAM_NOSWAP,1,ier); 79 | IF ( ier /= 1 ) CALL EXIT(105) 80 | 81 | CALL MMG2D_Set_iparameter(mesh,mmgMet,MMG2D_IPARAM_NOMOVE,1,ier); 82 | IF ( ier /= 1 ) CALL EXIT(106) 83 | 84 | CALL MMG2D_mmg2dmesh(mesh,mmgMet,ier) 85 | IF ( ier /= MMG5_SUCCESS ) CALL EXIT(200) 86 | 87 | !!> ------------------------------ STEP III -------------------------- 88 | !! Save the new data 89 | !! Use the MMG2D_saveMesh/MMG2D_saveAllSols functions 90 | !! save the mesh 91 | !> 1) Automatically save the mesh 92 | CALL MMG2D_saveVtkMesh(mesh,sol,TRIM(ADJUSTL(fileout)),LEN(TRIM(ADJUSTL(fileout))),ier) 93 | IF ( ier /= 1 ) CALL EXIT(300) 94 | 95 | !!> 3) Free the MMG2D structures 96 | CALL MMG2D_Free_all(MMG5_ARG_start, & 97 | MMG5_ARG_ppMesh,mesh,MMG5_ARG_ppMet,mmgMet, & 98 | MMG5_ARG_ppMet,sol, & 99 | MMG5_ARG_end) 100 | 101 | END PROGRAM main 102 | -------------------------------------------------------------------------------- /libexamples/mmg2d/squareGeneration_example0/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg2d library to perform mesh generation 2 | 3 | ## I/ Implementation 4 | To call the **mmg2d** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG2D library (**MMG2D_mmg2dmesh** function); 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMG2D_loadMesh** and **MMG2D_loadSol** functions. 10 | 11 | We ask for a maximal edge size of 0.1 using the **MMG2D_Set_dparameter** function. 12 | We increase the verbosity level using the **MMG2D_Set_iparameter** function. 13 | 14 | Results are saved using **MMG2D_saveMesh** and **MMG2D_saveSol** functions. 15 | 16 | 17 | ## II/ Compilation 18 | 1. Build and install the **mmg2d** shared and static library. We suppose in the following that you have installed the **mmg2d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 19 | 2. compile the main.c file specifying: 20 | * the **mmg2d** include directory with the **-I** option; 21 | * the **mmg2d** library location with the **-L** option; 22 | * the **mmg2d** library name with the **-l** option; 23 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 24 | 25 | > Example 1 26 | > Command line to link the application with the **mmg2d** static library 27 | > ```Shell 28 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d -lm 29 | > ``` 30 | 31 | > Example 2 32 | > Command line to link the application with the **mmg2d** shared library: 33 | > ```Shell 34 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg2d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg2d 35 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 36 | > ``` 37 | -------------------------------------------------------------------------------- /libexamples/mmg2d/squareGeneration_example0/carretest.mesh: -------------------------------------------------------------------------------- 1 | 2 | MeshVersionFormatted 3 | 1 4 | 5 | Dimension 6 | 2 7 | 8 | Vertices 9 | 26 10 | 11 | 0 0 0 12 | 1 0 0 13 | 1 1 0 14 | 0 1 0 15 | 0.828665 0.814528 0 16 | 0.419287 0.393238 0 17 | 0.199603 0.76555 0 18 | 1 0.204149 0 19 | 0.78567 0.336886 0 20 | 0.623672 0.761338 0 21 | 0.237883 0.231709 0 22 | 1 0.435241 0 23 | 0.210577 0.504206 0 24 | 0.595124 0.283152 0 25 | 1 0.716542 0 26 | 0.406696 0.654724 0 27 | 0 0.668818 0 28 | 0.807384 0.594758 0 29 | 0.705209 0 0 30 | 0 0.311194 0 31 | 0.459156 0.18162 0 32 | 0.71227 1 0 33 | 0.606302 0.504016 0 34 | 0.338281 0 0 35 | 0.380746 1 0 36 | 0.852605 0.102075 0 37 | 38 | 39 | Corners 40 | 4 41 | 42 | 1 43 | 2 44 | 3 45 | 4 46 | 47 | Edges 48 | 13 49 | 50 | 22 25 0 51 | 15 3 0 52 | 8 12 0 53 | 24 19 0 54 | 1 24 0 55 | 12 15 0 56 | 17 20 0 57 | 3 22 0 58 | 19 2 0 59 | 20 1 0 60 | 4 17 0 61 | 25 4 0 62 | 2 8 0 63 | 64 | Ridges 65 | 13 66 | 67 | 1 68 | 2 69 | 3 70 | 4 71 | 5 72 | 6 73 | 7 74 | 8 75 | 9 76 | 10 77 | 11 78 | 12 79 | 13 80 | 81 | End 82 | -------------------------------------------------------------------------------- /libexamples/mmg2d/squareGeneration_example0/main.c: -------------------------------------------------------------------------------- 1 | /*Authors Cécile Dobrzynski 2 | 3 | Example for using mmg2dlib 4 | 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | /** Include the mmg2d library hader file */ 16 | // if the header file is in the "include" directory 17 | // #include "libmmg2d.h" 18 | // if the header file is in "include/mmg/mmg2d" 19 | #include "mmg/mmg2d/libmmg2d.h" 20 | 21 | int main(int argc,char *argv[]) { 22 | MMG5_pMesh mmgMesh; 23 | MMG5_pSol mmgSol; 24 | char *filename, *outname; 25 | 26 | int ier; 27 | 28 | fprintf(stdout," -- TEST MMG2DMESH \n"); 29 | 30 | 31 | if ( argc != 3 ) { 32 | printf(" Usage: %s filein fileout \n",argv[0]); 33 | return(1); 34 | } 35 | 36 | /* Name and path of the mesh file */ 37 | filename = (char *) calloc(strlen(argv[1]) + 1, sizeof(char)); 38 | if ( filename == NULL ) { 39 | perror(" ## Memory problem: calloc"); 40 | exit(EXIT_FAILURE); 41 | } 42 | strcpy(filename,argv[1]); 43 | 44 | outname = (char *) calloc(strlen(argv[2]) + 1, sizeof(char)); 45 | if ( outname == NULL ) { 46 | perror(" ## Memory problem: calloc"); 47 | exit(EXIT_FAILURE); 48 | } 49 | strcpy(outname,argv[2]); 50 | 51 | /** ------------------------------ STEP I -------------------------- */ 52 | /** 1) Initialisation of mesh and sol structures */ 53 | /* args of InitMesh: 54 | * MMG5_ARG_start: we start to give the args of a variadic func 55 | * MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 56 | * &mmgMesh: pointer toward your MMG5_pMesh (that store your mesh) 57 | * MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 58 | * &mmgSol: pointer toward your MMG5_pSol (that store your metric) */ 59 | 60 | mmgMesh = NULL; 61 | mmgSol = NULL; 62 | MMG2D_Init_mesh(MMG5_ARG_start, 63 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 64 | MMG5_ARG_end); 65 | 66 | /** 2) Build mesh in MMG5 format */ 67 | /** Two solutions: just use the MMG2D_loadMesh function that will read a .mesh(b) 68 | file formatted or manually set your mesh using the MMG2D_Set* functions */ 69 | 70 | /** read the mesh in a mesh file */ 71 | MMG2D_loadMesh(mmgMesh,filename); 72 | 73 | /** Set parameters : for example set the maximal edge size to 0.1 */ 74 | MMG2D_Set_dparameter(mmgMesh,mmgSol,MMG2D_DPARAM_hmax,0.1); 75 | 76 | /** Higher verbosity level */ 77 | MMG2D_Set_iparameter(mmgMesh,mmgSol,MMG2D_IPARAM_verbose,5); 78 | 79 | 80 | /** Generate the mesh */ 81 | ier = MMG2D_mmg2dmesh(mmgMesh,mmgSol); 82 | 83 | if ( ier == MMG5_STRONGFAILURE ) { 84 | fprintf(stdout,"BAD ENDING OF MMG2DMESH: UNABLE TO SAVE MESH\n"); 85 | return(ier); 86 | } else if ( ier == MMG5_LOWFAILURE ) 87 | fprintf(stdout,"BAD ENDING OF MMG2DMESH\n"); 88 | 89 | /*save result*/ 90 | if ( MMG2D_saveMesh(mmgMesh,outname) != 1 ) 91 | exit(EXIT_FAILURE); 92 | 93 | /*save metric*/ 94 | if ( MMG2D_saveSol(mmgMesh,mmgSol,outname) != 1 ) 95 | exit(EXIT_FAILURE); 96 | 97 | /** 3) Free the MMG2D structures */ 98 | MMG2D_Free_all(MMG5_ARG_start, 99 | MMG5_ARG_ppMesh,&mmgMesh,MMG5_ARG_ppMet,&mmgSol, 100 | MMG5_ARG_end); 101 | 102 | free(filename); 103 | filename = NULL; 104 | 105 | 106 | free(outname); 107 | outname = NULL; 108 | 109 | return(0); 110 | } 111 | -------------------------------------------------------------------------------- /libexamples/mmg3d/IsosurfDiscretization_lsOnly/met.mesh: -------------------------------------------------------------------------------- 1 | plane.mesh -------------------------------------------------------------------------------- /libexamples/mmg3d/LagrangianMotion_example0/README.md: -------------------------------------------------------------------------------- 1 | # Example of basic use of library libmmg3d for a lagrangian motion test case 2 | 3 | ## I/ Implementation 4 | We read the mesh and displacement in files and then, we compute the volume displacement. 5 | 6 | ## II/ Compilation 7 | 1. Prerequisite: you must have build and install the SUscElas library (https://github.com/SUscTools/SUscElas) 8 | 1. Build and install the **mmg3d** shared and/or static library with the **USE_SUSCELAS** CMake's flag set to **ON**. We suppose in the following that you have installed the **mmg3d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 9 | 2. compile the main.c file specifying: 10 | * the **mmg3d** include directory with the **-I** option; 11 | * the **mmg3d** library location with the **-L** option; 12 | * the **mmg3d** library name with the **-l** option; 13 | * for the static library you must also link the executable with the **Elas** library, the math library and, if used for the **mmg3d** library compilation, the **scotch** and **scotcherr** libraries; 14 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 15 | 16 | > Example 1 17 | > Command line to link the application with the **mmg3d** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 18 | > ```Shell 19 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -L$SUSCELAS_PATH -lmmg3d -lElas -lscotch -lscotcherr -lm 20 | > ``` 21 | 22 | > Example 2 23 | > Command line to link the application with the **mmg3d** shared library: 24 | > ```Shell 25 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d 26 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 27 | > ``` 28 | -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg3d library 2 | 3 | ## I/ Implementation 4 | To call the **mmg3d** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG3D library; 7 | 3. get the final mesh and sol. 8 | 9 | ### example0_a 10 | We read mesh and solution files using the **MMG3D_loadMesh** and **MMG3D_loadSol** functions. 11 | Results are saved using **MMG3D_saveMesh** and **MMG3D_saveSol** functions. 12 | 13 | ### example0_b 14 | The mesh and solution are hard coded. 15 | They are build in MMG5 format using API functions and are recovered by the same way. 16 | We show how to recover the mesh/sol by writting it in a file. 17 | 18 | ## II/ Compilation 19 | 1. Build and install the **mmg3d** shared and static library. We suppose in the following that you have installed the **mmg3d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 20 | 2. compile the main.c file specifying: 21 | * the **mmg3d** include directory with the **-I** option; 22 | * the **mmg3d** library location with the **-L** option; 23 | * the **mmg3d** library name with the **-l** option; 24 | * for the static library you must also link the executable with, if used for the **mmg3d** library compilation, the scotch and scotcherr libraries and with the math library; 25 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 26 | 27 | > Example 1 28 | > Command line to link the application with the **mmg3d** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 29 | > ```Shell 30 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg3d -lscotch -lscotcherr -lm 31 | > ``` 32 | 33 | > Example 2 34 | > Command line to link the application with the **mmg3d** shared library: 35 | > ```Shell 36 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d 37 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 38 | > ``` 39 | -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0/example0_a/cube.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | Vertices 6 | 12 7 | 0 0 0 0 8 | 0.5 0 0 0 9 | 0.5 0 1 0 10 | 0 0 1 0 11 | 0 1 0 0 12 | 0.5 1 0 0 13 | 0.5 1 1 0 14 | 0 1 1 0 15 | 1 0 0 0 16 | 1 1 0 0 17 | 1 0 1 0 18 | 1 1 1 0 19 | 20 | Tetrahedra 21 | 12 22 | 1 4 2 8 1 23 | 8 3 2 7 1 24 | 5 2 6 8 1 25 | 5 8 1 2 1 26 | 7 2 8 6 1 27 | 2 4 3 8 1 28 | 9 2 3 7 2 29 | 7 11 9 12 2 30 | 6 9 10 7 2 31 | 6 7 2 9 2 32 | 12 9 7 10 2 33 | 9 3 11 7 2 34 | 35 | Triangles 36 | 20 37 | 1 4 8 3 38 | 1 2 4 3 39 | 8 3 7 3 40 | 5 8 6 3 41 | 5 6 2 3 42 | 5 2 1 3 43 | 5 1 8 3 44 | 7 6 8 3 45 | 4 3 8 3 46 | 2 3 4 3 47 | 9 3 2 4 48 | 11 9 12 4 49 | 7 11 12 4 50 | 6 7 10 4 51 | 6 10 9 4 52 | 6 9 2 4 53 | 12 10 7 4 54 | 12 9 10 4 55 | 3 11 7 4 56 | 9 11 3 4 57 | 58 | End 59 | -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0/example0_a/cube.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | SolAtVertices 6 | 12 7 | 1 1 8 | 0.5 9 | 0.5 10 | 0.5 11 | 0.5 12 | 0.5 13 | 0.5 14 | 0.5 15 | 0.5 16 | 0.5 17 | 0.5 18 | 0.5 19 | 0.5 20 | 21 | End -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0_fortran/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmg3d library for a Fortran call 2 | 3 | ## I/ Implementation 4 | To call the **mmg3d** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG5 library; 7 | 3. get the final mesh and sol. 8 | 9 | ### example0_a 10 | We read mesh and solution files using the **MMG3D_loadMesh** and **MMG3D_loadSol** functions. 11 | Results are saved using **MMG3D_saveMesh** and **MMG3D_saveSol** functions. 12 | 13 | ### example0_b 14 | The mesh and solution are hard coded. 15 | They are build in MMG5 format using API functions and are recovered by the same way. 16 | We show how to recover the mesh/sol by writting it in a file. 17 | 18 | ## II/ Compilation 19 | 1. Build and install the **mmg3d** shared and static library. We suppose in the following that you have installed the **mmg3d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 20 | 2. compile the main.c file specifying: 21 | * the **mmg3d** include directory with the **-I** option; 22 | * the **mmg3d** library location with the **-L** option; 23 | * the **mmg3d** library name with the **-l** option; 24 | * for the static library you must also link the executable with, if used for the **mmg3d** library compilation, the scotch and scotcherr libraries and with the math library; 25 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 26 | 27 | > Example 1 28 | > Command line to link the application with the **mmg3d** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 29 | > ```Shell 30 | > gfortran -I$CMAKE_INSTALL_PREFIX/include main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg3d -lscotch -lscotcherr -lm 31 | > ``` 32 | 33 | > Example 2 34 | > Command line to link the application with the **mmg3d** shared library: 35 | > ```Shell 36 | > gfortran -I$CMAKE_INSTALL_PREFIX/include main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d 37 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 38 | > ``` 39 | -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0_fortran/example0_a/cube.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | Vertices 6 | 12 7 | 0 0 0 0 8 | 0.5 0 0 0 9 | 0.5 0 1 0 10 | 0 0 1 0 11 | 0 1 0 0 12 | 0.5 1 0 0 13 | 0.5 1 1 0 14 | 0 1 1 0 15 | 1 0 0 0 16 | 1 1 0 0 17 | 1 0 1 0 18 | 1 1 1 0 19 | 20 | Tetrahedra 21 | 12 22 | 1 4 2 8 1 23 | 8 3 2 7 1 24 | 5 2 6 8 1 25 | 5 8 1 2 1 26 | 7 2 8 6 1 27 | 2 4 3 8 1 28 | 9 2 3 7 2 29 | 7 11 9 12 2 30 | 6 9 10 7 2 31 | 6 7 2 9 2 32 | 12 9 7 10 2 33 | 9 3 11 7 2 34 | 35 | Triangles 36 | 20 37 | 1 4 8 3 38 | 1 2 4 3 39 | 8 3 7 3 40 | 5 8 6 3 41 | 5 6 2 3 42 | 5 2 1 3 43 | 5 1 8 3 44 | 7 6 8 3 45 | 4 3 8 3 46 | 2 3 4 3 47 | 9 3 2 4 48 | 11 9 12 4 49 | 7 11 12 4 50 | 6 7 10 4 51 | 6 10 9 4 52 | 6 9 2 4 53 | 12 10 7 4 54 | 12 9 10 4 55 | 3 11 7 4 56 | 9 11 3 4 57 | 58 | End 59 | -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0_fortran/example0_a/cube.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | SolAtVertices 6 | 12 7 | 1 1 8 | 0.5 9 | 0.5 10 | 0.5 11 | 0.5 12 | 0.5 13 | 0.5 14 | 0.5 15 | 0.5 16 | 0.5 17 | 0.5 18 | 0.5 19 | 0.5 20 | 21 | End -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example0_fortran/example0_a/main.F90: -------------------------------------------------------------------------------- 1 | !> @author 2 | !> Cecile Dobrzynski, Charles Dapogny, Pascal Frey and Algiane Froehly 3 | !> @brief 4 | !> Example for using mmg3dlib (basic use) 5 | 6 | PROGRAM main 7 | 8 | IMPLICIT NONE 9 | 10 | !> Include here the mmg3d library hader file 11 | ! if the header file is in the "include" directory 12 | ! #include "libmmg3df.h" 13 | 14 | ! if the header file is in "include/mmg/mmg3d" 15 | #include "mmg/mmg3d/libmmg3df.h" 16 | 17 | MMG5_DATA_PTR_T :: mmgMesh 18 | MMG5_DATA_PTR_T :: mmgSol 19 | INTEGER :: ier,argc 20 | CHARACTER(len=300) :: exec_name,filename,fileout 21 | 22 | WRITE(*,*) " -- TEST MMG3DLIB" 23 | 24 | argc = COMMAND_ARGUMENT_COUNT(); 25 | CALL get_command_argument(0, exec_name) 26 | 27 | IF ( argc /=2 ) THEN 28 | PRINT*," Usage: ",TRIM(exec_name)," input_file_name output_filename" 29 | CALL EXIT(1); 30 | ENDIF 31 | 32 | ! Name and path of the mesh file 33 | CALL get_command_argument(1, filename) 34 | CALL get_command_argument(2, fileout) 35 | 36 | !> ------------------------------ STEP I -------------------------- 37 | !! 1) Initialisation of mesh and sol structures 38 | !! args of InitMesh: 39 | !! MMG5_ARG_start: we start to give the args of a variadic func 40 | !! MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 41 | !! mmgMesh: your MMG5_pMesh (that store your mesh) 42 | !! MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 43 | !! mmgSol: your MMG5_pSol (that store your metric) */ 44 | 45 | mmgMesh = 0 46 | mmgSol = 0 47 | 48 | CALL MMG3D_Init_mesh(MMG5_ARG_start, & 49 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgSol, & 50 | MMG5_ARG_end) 51 | 52 | !> 2) Build mesh in MMG5 format 53 | !! Two solutions: just use the MMG3D_loadMesh function that will read a .mesh(b) 54 | !! file formatted or manually set your mesh using the MMG3D_Set* functions 55 | 56 | !> with MMG3D_loadMesh function 57 | CALL MMG3D_loadMesh(mmgMesh,TRIM(ADJUSTL(filename)),& 58 | LEN(TRIM(ADJUSTL(filename))),ier) 59 | IF ( ier == 0 ) CALL EXIT(102) 60 | 61 | !> 3) Build sol in MMG5 format 62 | !! Two solutions: just use the MMG3D_loadSol function that will read a .sol(b) 63 | !! file formatted or manually set your sol using the MMG3D_Set* functions 64 | 65 | !> With MMG3D_loadSol function 66 | CALL MMG3D_loadSol(mmgMesh,mmgSol,TRIM(ADJUSTL(filename)),& 67 | LEN(TRIM(ADJUSTL(filename))),ier) 68 | IF ( ier /= 1 ) THEN 69 | CALL EXIT(104) 70 | ENDIF 71 | 72 | !> 4) (not mandatory): check if the number of given entities match with mesh size 73 | CALL MMG3D_Chk_meshData(mmgMesh,mmgSol,ier) 74 | IF ( ier /= 1 ) CALL EXIT(105) 75 | 76 | !> ------------------------------ STEP II -------------------------- 77 | !! remesh function 78 | CALL MMG3D_mmg3dlib(mmgMesh,mmgSol,ier) 79 | 80 | IF ( ier == MMG5_STRONGFAILURE ) THEN 81 | PRINT*,"BAD ENDING OF MMG3DLIB: UNABLE TO SAVE MESH" 82 | STOP 2 83 | ELSE IF ( ier == MMG5_LOWFAILURE ) THEN 84 | PRINT*,"BAD ENDING OF MMG3DLIB" 85 | ENDIF 86 | 87 | !> ------------------------------ STEP III -------------------------- 88 | !! get results 89 | !! Two solutions: just use the MMG3D_saveMesh/MMG3D_saveSol functions 90 | !! that will write .mesh(b)/.sol formatted files or manually get your mesh/sol 91 | !! using the MMG3D_getMesh/MMG3D_getSol functions 92 | 93 | !> 1) Automatically save the mesh 94 | CALL MMG3D_saveMesh(mmgMesh,TRIM(ADJUSTL(fileout)),& 95 | LEN(TRIM(ADJUSTL(fileout))),ier) 96 | IF ( ier /= 1 ) THEN 97 | CALL EXIT(106) 98 | ENDIF 99 | 100 | !> 2) Automatically save the solution 101 | CALL MMG3D_saveSol(mmgMesh,mmgSol,TRIM(ADJUSTL(fileout)),& 102 | LEN(TRIM(ADJUSTL(fileout))),ier) 103 | IF ( ier /= 1 ) THEN 104 | CALL EXIT(107) 105 | ENDIF 106 | 107 | !> 3) Free the MMG3D5 structures 108 | CALL MMG3D_Free_all(MMG5_ARG_start, & 109 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgSol, & 110 | MMG5_ARG_end) 111 | 112 | END PROGRAM main 113 | -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example1/README.md: -------------------------------------------------------------------------------- 1 | #Example to move from mmg3d4 library to mmg3d5 library 2 | 3 | * the **_main.cold_** correspond to a mmg3d4 library call; 4 | * the **_main.c_** is the same code but with a call to the new mmg3d library (5.x.x release). 5 | 6 | It is strongly advised to use the mmg3d5 API functions instead of hard setting your mesh as it was required by the mmg3d4 library. 7 | 8 | **Remarks:** 9 | * You will find the same example (with additionnal boundary triangles) in the **_example0_** directory; 10 | * please, refer to the **_example0_** directory to have an example of _"clean"_ call of the new **mmg3d** library and to see how to build the example executable. -------------------------------------------------------------------------------- /libexamples/mmg3d/adaptation_example2/README.md: -------------------------------------------------------------------------------- 1 | # Example of advanced use of library libmmg3d 2 | 3 | ## I/ Implementation 4 | We read the mesh and solution in files. 5 | 6 | * First we remesh in debug mode: 7 | * we ask for a minimal size of 0.001, a maximal size of 40, a gradation of 2 and a global hausdorff value (applied on all the boundaries) of 0.1; 8 | * we save the mesh and solution. 9 | 10 | * Second, we remesh in normal mode, with specified memory and lower verbosity: 11 | * in addition to previous parameters, we ask that all boundary triangles of ref 36 respect a hasdorff number of 0.01 and all boundary triangles of ref 38 a hasdorff number of 1. For both reference, we set the minimal (resp. maximal) edge size to 0.00001 (resp. 40). 12 | The local hausdorff number on ref 38 has no effects because it is higher than the previous value (without local value, we apply global hausdorff (0.1)) and this value is now contained in the metric; 13 | * we don't save results but we reset the computed metric and reapply the initial constant metric of size 10; 14 | * we perform the last wave of refinment. Now we can see the effect of the local hausdorff number on ref 38; 15 | * we save the mesh and solution 16 | 17 | ## II/ Compilation 18 | 1. Build and install the **mmg3d** shared and static library. We suppose in the following that you have installed the **mmg3d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 19 | 2. compile the main.c file specifying: 20 | * the **mmg3d** include directory with the **-I** option; 21 | * the **mmg3d** library location with the **-L** option; 22 | * the **mmg3d** library name with the **-l** option; 23 | * for the static library you must also link the executable with, if used for the **mmg3d** library compilation, the scotch and scotcherr libraries and with the math library; 24 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 25 | 26 | > Example 1 27 | > Command line to link the application with the **mmg3d** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 28 | > ```Shell 29 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmg3d -lscotch -lscotcherr -lm 30 | > ``` 31 | 32 | > Example 2 33 | > Command line to link the application with the **mmg3d** shared library: 34 | > ```Shell 35 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d 36 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 37 | > ``` 38 | -------------------------------------------------------------------------------- /libexamples/mmg3d/io_generic_and_get_adja/cube.vtk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg3d/io_generic_and_get_adja/cube.vtk -------------------------------------------------------------------------------- /libexamples/mmg3d/io_generic_and_get_adja/cube.vtu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MmgTools/mmg/4d8232c8aebfed877935d75d4d4a67e850962422/libexamples/mmg3d/io_generic_and_get_adja/cube.vtu -------------------------------------------------------------------------------- /libexamples/mmg3d/io_multisols_example6/README.md: -------------------------------------------------------------------------------- 1 | # Input and output for multiple solutions (we do not call any mmg library here) 2 | 3 | ## I/ Implementation 4 | 1. Read a mesh and a solution file with multiple solutions at MMG5 format 5 | (using the **MMG3D_loadMesh** and **MMG3D_loadAllSols** functions). 6 | 2. Use the Mmg setters to set this solutions in another solution structure. 7 | 3. Use the Mmg getters to get the solutions in another new solution structure. 8 | 4. Save this last solution structure and the multiple solutions stored using 9 | the **MMG3D_saveAllSols** function. 10 | 11 | ## II/ Compilation 12 | 1. Build and install the **mmg3d** shared and static library. We suppose in the following that you have installed the **mmg3d** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 13 | 2. compile the main.c file specifying: 14 | * the **mmg3d** include directory with the **-I** option; 15 | * the **mmg3d** library location with the **-L** option; 16 | * the **mmg3d** library name with the **-l** option; 17 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 18 | 19 | > Example 1 20 | > Command line to link the application with the **mmg3d** static library 21 | > ```Shell 22 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d -lm 23 | > ``` 24 | 25 | > Example 2 26 | > Command line to link the application with the **mmg3d** shared library: 27 | > ```Shell 28 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmg3d main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmg3d 29 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 30 | > ``` 31 | -------------------------------------------------------------------------------- /libexamples/mmgs/IsosurfDiscretization_example0/README.md: -------------------------------------------------------------------------------- 1 | # Example of basic use of library libmmgs for a level-set discretization test case 2 | 3 | ## I/ Implementation 4 | We read the mesh and level-set values at the mesh nodes and then, we discretize the implicit function and optimize the mesh. 5 | 6 | ## II/ Compilation 7 | 1. Build and install the **mmgs** shared and/or static library. We suppose in the following that you have installed the **mmgs** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 8 | 2. compile the main.c file specifying: 9 | * the **mmgs** include directory with the **-I** option; 10 | * the **mmgs** library location with the **-L** option; 11 | * the **mmgs** library name with the **-l** option; 12 | * for the static library you must also link the executable with the math library and, if used for the **mmgs** library compilation, the **scotch** and **scotcherr** libraries; 13 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 14 | 15 | > Example 1 16 | > Command line to link the application with the **mmgs** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 17 | > ```Shell 18 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmgs -lscotch -lscotcherr -lm 19 | > ``` 20 | 21 | > Example 2 22 | > Command line to link the application with the **mmgs** shared library: 23 | > ```Shell 24 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs 25 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 26 | > ``` 27 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmgs library for an adaptation testcase 2 | 3 | ## I/ Implementation 4 | To call the **mmgs** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMGS library; 7 | 3. get the final mesh and sol. 8 | 9 | ### example0_a 10 | We read mesh and solution files using the **MMGS_loadMesh** and **MMGS_loadSol** functions. 11 | Results are saved using **MMGS_saveMesh** and **MMGS_saveSol** functions. 12 | 13 | ### example0_b 14 | The mesh and solution are hard coded. 15 | They are build in MMG5 format using API functions and are recovered by the same way. 16 | We show how to recover the mesh/sol. 17 | 18 | ## II/ Compilation 19 | 1. Build and install the **mmgs** shared and static library. We suppose in the following that you have installed the **mmgs** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 20 | 2. compile the main.c file specifying: 21 | * the **mmgs** include directory with the **-I** option; 22 | * the **mmgs** library location with the **-L** option; 23 | * the **mmgs** library name with the **-l** option; 24 | * for the static library you must also link the executable with, if used for the **mmgs** library compilation, the scotch and scotcherr libraries and with the math library; 25 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 26 | 27 | > Example 1 28 | > Command line to link the application with the **mmgs** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 29 | > ```Shell 30 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmgs -lscotch -lscotcherr -lm 31 | > ``` 32 | 33 | > Example 2 34 | > Command line to link the application with the **mmgs** shared library: 35 | > ```Shell 36 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs 37 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 38 | > ``` 39 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0/example0_a/cube.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | Vertices 6 | 12 7 | 0 0 0 0 8 | 0.5 0 0 0 9 | 0.5 0 1 0 10 | 0 0 1 0 11 | 0 1 0 0 12 | 0.5 1 0 0 13 | 0.5 1 1 0 14 | 0 1 1 0 15 | 1 0 0 0 16 | 1 1 0 0 17 | 1 0 1 0 18 | 1 1 1 0 19 | 20 | Tetrahedra 21 | 12 22 | 1 4 2 8 1 23 | 8 3 2 7 1 24 | 5 2 6 8 1 25 | 5 8 1 2 1 26 | 7 2 8 6 1 27 | 2 4 3 8 1 28 | 9 2 3 7 2 29 | 7 11 9 12 2 30 | 6 9 10 7 2 31 | 6 7 2 9 2 32 | 12 9 7 10 2 33 | 9 3 11 7 2 34 | 35 | Triangles 36 | 20 37 | 1 4 8 3 38 | 1 2 4 3 39 | 8 3 7 3 40 | 5 8 6 3 41 | 5 6 2 3 42 | 5 2 1 3 43 | 5 1 8 3 44 | 7 6 8 3 45 | 4 3 8 3 46 | 2 3 4 3 47 | 9 3 2 4 48 | 11 9 12 4 49 | 7 11 12 4 50 | 6 7 10 4 51 | 6 10 9 4 52 | 6 9 2 4 53 | 12 10 7 4 54 | 12 9 10 4 55 | 3 11 7 4 56 | 9 11 3 4 57 | 58 | End 59 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0/example0_a/cube.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | SolAtVertices 6 | 12 7 | 1 1 8 | 0.5 9 | 0.5 10 | 0.5 11 | 0.5 12 | 0.5 13 | 0.5 14 | 0.5 15 | 0.5 16 | 0.5 17 | 0.5 18 | 0.5 19 | 0.5 20 | 21 | End -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0_fortran/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmgs library for a Fortran call 2 | 3 | ## I/ Implementation 4 | To call the **mmgs** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMG5 library; 7 | 3. get the final mesh and sol. 8 | 9 | ### example0_a 10 | We read mesh and solution files using the **MMGS_loadMesh** and **MMGS_loadSol** functions. 11 | Results are saved using **MMGS_saveMesh** and **MMGS_saveSol** functions. 12 | 13 | ### example0_b 14 | The mesh and solution are hard coded. 15 | They are build in MMG5 format using API functions and are recovered by the same way. 16 | We show how to recover the mesh/sol. 17 | 18 | ## II/ Compilation 19 | 1. Build and install the **mmgs** shared and static library. We suppose in the following that you have installed the **mmgs** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 20 | 2. compile the main.c file specifying: 21 | * the **mmgs** include directory with the **-I** option; 22 | * the **mmgs** library location with the **-L** option; 23 | * the **mmgs** library name with the **-l** option; 24 | * for the static library you must also link the executable with, if used for the **mmgs** library compilation, the scotch and scotcherr libraries and with the math library; 25 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 26 | 27 | > Example 1 28 | > Command line to link the application with the **mmgs** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 29 | > ```Shell 30 | > gfortran -I$CMAKE_INSTALL_PREFIX/include main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmgs -lscotch -lscotcherr -lm 31 | > ``` 32 | 33 | > Example 2 34 | > Command line to link the application with the **mmgs** shared library: 35 | > ```Shell 36 | > gfortran -I$CMAKE_INSTALL_PREFIX/include main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs 37 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 38 | > ``` 39 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0_fortran/example0_a/README.md: -------------------------------------------------------------------------------- 1 | # Basic use of the mmgs library for a Fortran call (adaptation test case) 2 | 3 | ## I/ Implementation 4 | To call the **mmgs** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMGS library; 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMGS_loadMesh** and **MMGS_loadSol** functions. 10 | Results are saved using **MMGS_saveMesh** and **MMGS_saveSol** functions. 11 | 12 | ## II/ Compilation 13 | 1. Build and install the **mmgs** shared and static library. We suppose in the following that you have installed the **mmgs** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 14 | 2. compile the main.c file specifying: 15 | * the **mmgs** include directory with the **-I** option; 16 | * the **mmgs** library location with the **-L** option; 17 | * the **mmgs** library name with the **-l** option; 18 | * for the static library you must also link the executable with, if used for the **mmgs** library compilation, the scotch and scotcherr libraries and with the math library; 19 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 20 | 21 | > Example 1 22 | > Command line to link the application with the **mmgs** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 23 | > ```Shell 24 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmgs -lscotch -lscotcherr -lm 25 | > ``` 26 | 27 | > Example 2 28 | > Command line to link the application with the **mmgs** shared library: 29 | > ```Shell 30 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs 31 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 32 | > ``` 33 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0_fortran/example0_a/cube.mesh: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | Vertices 6 | 12 7 | 0 0 0 0 8 | 0.5 0 0 0 9 | 0.5 0 1 0 10 | 0 0 1 0 11 | 0 1 0 0 12 | 0.5 1 0 0 13 | 0.5 1 1 0 14 | 0 1 1 0 15 | 1 0 0 0 16 | 1 1 0 0 17 | 1 0 1 0 18 | 1 1 1 0 19 | 20 | Tetrahedra 21 | 12 22 | 1 4 2 8 1 23 | 8 3 2 7 1 24 | 5 2 6 8 1 25 | 5 8 1 2 1 26 | 7 2 8 6 1 27 | 2 4 3 8 1 28 | 9 2 3 7 2 29 | 7 11 9 12 2 30 | 6 9 10 7 2 31 | 6 7 2 9 2 32 | 12 9 7 10 2 33 | 9 3 11 7 2 34 | 35 | Triangles 36 | 20 37 | 1 4 8 3 38 | 1 2 4 3 39 | 8 3 7 3 40 | 5 8 6 3 41 | 5 6 2 3 42 | 5 2 1 3 43 | 5 1 8 3 44 | 7 6 8 3 45 | 4 3 8 3 46 | 2 3 4 3 47 | 9 3 2 4 48 | 11 9 12 4 49 | 7 11 12 4 50 | 6 7 10 4 51 | 6 10 9 4 52 | 6 9 2 4 53 | 12 10 7 4 54 | 12 9 10 4 55 | 3 11 7 4 56 | 9 11 3 4 57 | 58 | End 59 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0_fortran/example0_a/cube.sol: -------------------------------------------------------------------------------- 1 | MeshVersionFormatted 2 2 | 3 | Dimension 3 4 | 5 | SolAtVertices 6 | 12 7 | 1 1 8 | 0.5 9 | 0.5 10 | 0.5 11 | 0.5 12 | 0.5 13 | 0.5 14 | 0.5 15 | 0.5 16 | 0.5 17 | 0.5 18 | 0.5 19 | 0.5 20 | 21 | End -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example0_fortran/example0_a/main.F90: -------------------------------------------------------------------------------- 1 | !> @author 2 | !> Cecile Dobrzynski, Charles Dapogny, Pascal Frey and Algiane Froehly 3 | !> @brief 4 | !> Example for using mmgslib (basic use) 5 | 6 | PROGRAM main 7 | 8 | IMPLICIT NONE 9 | 10 | !> Include the mmgs library hader file 11 | ! if the header file is in the "include" directory 12 | ! #include "libmmgsf.h" 13 | 14 | ! if the header file is in "include/mmg/mmgs" 15 | #include "mmg/mmgs/libmmgsf.h" 16 | 17 | 18 | MMG5_DATA_PTR_T :: mmgMesh 19 | MMG5_DATA_PTR_T :: mmgSol 20 | INTEGER :: ier,argc 21 | CHARACTER(len=300) :: exec_name,filename,fileout 22 | 23 | WRITE(*,*) " -- TEST MMGSLIB" 24 | 25 | argc = COMMAND_ARGUMENT_COUNT(); 26 | CALL get_command_argument(0, exec_name) 27 | 28 | IF ( argc /=2 ) THEN 29 | PRINT*," Usage: ",TRIM(exec_name)," input_file_name output_file_name" 30 | CALL EXIT(1); 31 | ENDIF 32 | 33 | ! Name and path of the mesh file 34 | CALL get_command_argument(1, filename) 35 | CALL get_command_argument(2, fileout) 36 | 37 | !> ------------------------------ STEP I -------------------------- 38 | !! 1) Initialisation of mesh and sol structures 39 | !! args of InitMesh: 40 | !! MMG5_ARG_start: we start to give the args of a variadic func 41 | !! MMG5_ARG_ppMesh: next arg will be a pointer over a MMG5_pMesh 42 | !! mmgMesh: your MMG5_pMesh (that store your mesh) 43 | !! MMG5_ARG_ppMet: next arg will be a pointer over a MMG5_pSol storing a metric 44 | !! mmgSol: your MMG5_pSol (that store your metric) */ 45 | mmgMesh = 0 46 | mmgSol = 0 47 | 48 | CALL MMGS_Init_mesh(MMG5_ARG_start, & 49 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgSol, & 50 | MMG5_ARG_end) 51 | 52 | !> 2) Build mesh in MMG5 format 53 | !! Two solutions: just use the MMGS_loadMesh function that will read a .mesh(b) 54 | !! file formatted or manually set your mesh using the MMGS_Set* functions 55 | 56 | !> with MMGS_loadMesh function 57 | CALL MMGS_loadMesh(mmgMesh,TRIM(ADJUSTL(filename)),& 58 | LEN(TRIM(ADJUSTL(filename))),ier) 59 | IF ( ier /= 1 ) CALL EXIT(102) 60 | 61 | !> 3) Build sol in MMG5 format 62 | !! Two solutions: just use the MMGS_loadSol function that will read a .sol(b) 63 | !! file formatted or manually set your sol using the MMGS_Set* functions 64 | 65 | !> With MMGS_loadSol function 66 | CALL MMGS_loadSol(mmgMesh,mmgSol,TRIM(ADJUSTL(filename)),& 67 | LEN(TRIM(ADJUSTL(filename))),ier) 68 | IF ( ier /= 1 ) THEN 69 | CALL EXIT(104) 70 | ENDIF 71 | 72 | !> 4) (not mandatory): check if the number of given entities match with mesh size 73 | CALL MMGS_Chk_meshData(mmgMesh,mmgSol,ier) 74 | IF ( ier /= 1 ) CALL EXIT(105) 75 | 76 | !> ------------------------------ STEP II -------------------------- 77 | !! remesh function 78 | !! Remark: %val(0) allow to pass the value 0 (i.e. NULL) instead of a pointer 79 | !! toward NULL. 80 | CALL MMGS_mmgslib(mmgMesh,mmgSol,ier) 81 | IF ( ier == MMG5_STRONGFAILURE ) THEN 82 | PRINT*,"BAD ENDING OF MMGSLIB: UNABLE TO SAVE MESH" 83 | STOP 2 84 | ELSE IF ( ier == MMG5_LOWFAILURE ) THEN 85 | PRINT*,"BAD ENDING OF MMGSLIB" 86 | ENDIF 87 | 88 | !> ------------------------------ STEP III -------------------------- 89 | !! get results 90 | !! Two solutions: just use the MMGS_saveMesh/MMGS_saveSol functions 91 | !! that will write .mesh(b)/.sol formatted files or manually get your mesh/sol 92 | !! using the MMGS_getMesh/MMGS_getSol functions 93 | 94 | !> 1) Automatically save the mesh 95 | CALL MMGS_saveMesh(mmgMesh,TRIM(ADJUSTL(fileout)),LEN(TRIM(ADJUSTL(fileout))),ier) 96 | IF ( ier /= 1 ) CALL EXIT(106) 97 | 98 | !> 2) Automatically save the solution 99 | CALL MMGS_saveSol(mmgMesh,mmgSol,TRIM(ADJUSTL(fileout)),LEN(TRIM(ADJUSTL(fileout))),ier) 100 | IF ( ier /= 1 ) CALL EXIT(107) 101 | 102 | !> 3) Free the MMGS5 structures 103 | CALL MMGS_Free_all(MMG5_ARG_start, & 104 | MMG5_ARG_ppMesh,mmgMesh,MMG5_ARG_ppMet,mmgSol, & 105 | MMG5_ARG_end) 106 | 107 | END PROGRAM main 108 | -------------------------------------------------------------------------------- /libexamples/mmgs/adaptation_example1/README.md: -------------------------------------------------------------------------------- 1 | # Advanced use of the mmgs library for an adaptation test case 2 | 3 | ## I/ Implementation 4 | To call the **mmgs** library, you must: 5 | 1. build mesh and sol at MMG5 format; 6 | 2. call the MMGS library; 7 | 3. get the final mesh and sol. 8 | 9 | We read mesh and solution files using the **MMGS_loadMesh** and **MMGS_loadSol** functions. 10 | 11 | * First we remesh in debug mode: 12 | * we ask for a minimal size of 0.001, a maximal size of 40, a gradation of 2 and a global hausdorff value (applied on all the boundaries) of 0.1; 13 | * we save results. 14 | 15 | * Second, we remesh in normal mode, with specified memory and lower verbosity: 16 | * in addition to previous parameters, we ask that all boundary triangles of ref 36 respect a minimal edge size of 0.005 and a maximal one of 0.05 and all boundary triangles of ref 38 must respect a minimal edges size of 0.1 and a maximal one of 1. For both reference, we set the hausdorff value to 1. 17 | * we save the mesh and solution. 18 | 19 | ## II/ Compilation 20 | 1. Build and install the **mmgs** shared and static library. We suppose in the following that you have installed the **mmgs** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 21 | 2. compile the main.c file specifying: 22 | * the **mmgs** include directory with the **-I** option; 23 | * the **mmgs** library location with the **-L** option; 24 | * the **mmgs** library name with the **-l** option; 25 | * for the static library you must also link the executable with, if used for the **mmgs** library compilation, the scotch and scotcherr libraries and with the math library; 26 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 27 | 28 | > Example 1 29 | > Command line to link the application with the **mmgs** static library (we supposed here that the scotch library is installed in the **_$SCOTCH_PATH_** directory): 30 | > ```Shell 31 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -L$SCOTCH_PATH -lmmgs -lscotch -lscotcherr -lm 32 | > ``` 33 | 34 | > Example 2 35 | > Command line to link the application with the **mmgs** shared library: 36 | > ```Shell 37 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs 38 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 39 | > ``` -------------------------------------------------------------------------------- /libexamples/mmgs/io_multisols_example3/README.md: -------------------------------------------------------------------------------- 1 | # Input and output for multiple solutions (we do not call any mmg library here) 2 | 3 | ## I/ Implementation 4 | 1. Read a mesh and a solution file with multiple solutions at MMG5 format 5 | (using the **MMGS_loadMesh** and **MMGS_loadAllSols** functions). 6 | 2. Use the Mmg setters to set this solutions in another solution structure. 7 | 3. Use the Mmg getters to get the solutions in another new solution structure. 8 | 4. Save this last solution structure and the multiple solutions stored using 9 | the **MMGS_saveAllSols** function. 10 | 11 | ## II/ Compilation 12 | 1. Build and install the **mmgs** shared and static library. We suppose in the following that you have installed the **mmgs** library in the **_$CMAKE_INSTALL_PREFIX_** directory (see the [installation](https://github.com/MmgTools/Mmg/wiki/Setup-guide#iii-installation) section of the setup guide); 13 | 2. compile the main.c file specifying: 14 | * the **mmgs** include directory with the **-I** option; 15 | * the **mmgs** library location with the **-L** option; 16 | * the **mmgs** library name with the **-l** option; 17 | * with the shared library, you must add the ***_$CMAKE_INSTALL_PREFIX_** directory to your **LD_LIBRARY_PATH**. 18 | 19 | > Example 1 20 | > Command line to link the application with the **mmgs** static library 21 | > ```Shell 22 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs -lm 23 | > ``` 24 | 25 | > Example 2 26 | > Command line to link the application with the **mmgs** shared library: 27 | > ```Shell 28 | > gcc -I$CMAKE_INSTALL_PREFIX/include/mmg/mmgs main.c -L$CMAKE_INSTALL_PREFIX/lib -lmmgs 29 | > export LD_LIBRARY_PATH=$CMAKE_INSTALL_PREFIX/lib:$LD_LIBRARY_PATH 30 | > ``` 31 | -------------------------------------------------------------------------------- /scripts/genheader.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /**************************************** 25 | * genheader.c 26 | * 27 | * generate an executable to generate 28 | * headers for Fortran mmg users. 29 | * Used by makefile 30 | ****************************************/ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /* 38 | Program: genheader 39 | 40 | Generate headers (for fortran) setting MMG5_DATA_PTR 41 | macro to the correct value. 42 | 43 | Parameters: 44 | argc - must be 3 45 | argv - contains the names wanted for the Fortran header 46 | 47 | Returns: 48 | EXIT_SUCCESS 49 | 50 | */ 51 | int main (int argc, char ** argv) 52 | { 53 | char * header_f = NULL; 54 | char * libmmg_h = NULL; 55 | char * libmmg_include = NULL; 56 | char * genfort = NULL; 57 | char * cmd = NULL; 58 | FILE * file = NULL; 59 | 60 | if (argc != 5) 61 | { 62 | fprintf(stderr, "usage : %s headerNameFortran.h headerNameC.h" 63 | " libmmgtypesf_include_dir genfort.pl\n",argv[0]); 64 | return EXIT_FAILURE; 65 | } 66 | 67 | header_f = argv[1]; 68 | libmmg_h = argv[2]; 69 | libmmg_include = argv[3]; 70 | genfort = argv[4]; 71 | 72 | /* Fortran header */ 73 | file = fopen (header_f,"w"); 74 | 75 | if ( file == NULL ) 76 | return(EXIT_FAILURE); 77 | 78 | fprintf(file,"! /* This file is automatically generated by the" 79 | "\"genheader.c\" code\n"); 80 | fprintf(file,"! ** and the \"genfort.pl\" script (scripts directory).\n"); 81 | fprintf(file,"! ** Do not modified it by hand, it will be discarded.\n"); 82 | fprintf(file,"! **\n"); 83 | fprintf(file,"! ** This scripts recopy the macros of the libmmg*.h file\n"); 84 | fprintf(file,"! ** and convert enumerations into macros.\n"); 85 | fprintf(file,"! **\n"); 86 | fprintf(file,"! ** Note: \"genfort.pl\" is automatically called by the "); 87 | fprintf(file,"\"genheader.c\"\n! ** executable code.\n"); 88 | fprintf(file,"! **\n"); 89 | fprintf(file,"! ** See the \"libmmg*.h\" file for a correct displaying of" 90 | " the documentation.\n"); 91 | fprintf(file,"! */\n\n"); 92 | 93 | /* Include libmmgtypesf.h if needed. */ 94 | if(strstr(libmmg_h,"libmmgtypes.h")==NULL) { 95 | fprintf(file,"#include \"%s/libmmgtypesf.h\"\n\n",libmmg_include); 96 | } 97 | else { 98 | /* Compute the size of the C pointer for the Fortran programm */ 99 | fprintf(file, "#define MMG5_DATA_PTR_T INTEGER(kind=%d)\n", 100 | (int)sizeof(void*)); 101 | fprintf(file, "#include \"mmg/common/mmgversion.h\"\n"); 102 | fprintf(file, "#include \"mmg/common/mmgcmakedefinesf.h\"\n\n"); 103 | } 104 | fclose(file); 105 | 106 | /* Generate Fortran header */ 107 | if (NULL == (cmd = (char*)malloc((strlen(genfort)+ 108 | strlen(libmmg_h)+ 109 | strlen(header_f)+128)*sizeof(char)))) 110 | return EXIT_FAILURE; 111 | sprintf(cmd, "perl %s -f %s >> %s;", 112 | genfort, libmmg_h, header_f); 113 | fprintf(stdout, "%s\n", cmd); 114 | if (-1 == system(cmd)) 115 | return EXIT_FAILURE; 116 | free(cmd); 117 | 118 | return(0); 119 | } 120 | -------------------------------------------------------------------------------- /scripts/git_log_mmg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # get arguments 4 | CMAKE_SOURCE_DIR=$1 5 | MMG_BINARY_DIR=$2 6 | HEADER_FILE="git_log_mmg.h" 7 | 8 | # test if $HEADER_FILE is present 9 | if [ ! -f "$MMG_BINARY_DIR/$HEADER_FILE" ]; then 10 | \touch $MMG_BINARY_DIR/$HEADER_FILE 11 | echo "#ifndef _GIT_LOG_MMG_H" >> "$MMG_BINARY_DIR/$HEADER_FILE" 12 | echo "#define _GIT_LOG_MMG_H" >> "$MMG_BINARY_DIR/$HEADER_FILE" 13 | echo "#define MMG_GIT_BRANCH \"No git branch found\"" >> "$MMG_BINARY_DIR/$HEADER_FILE" 14 | echo "#define MMG_GIT_COMMIT \"No git commit found\"" >> "$MMG_BINARY_DIR/$HEADER_FILE" 15 | echo "#define MMG_GIT_DATE \"No git commit found\"" >> "$MMG_BINARY_DIR/$HEADER_FILE" 16 | echo "#endif" >> "$MMG_BINARY_DIR/$HEADER_FILE" 17 | fi 18 | 19 | # parameter 20 | git_is_present=1 21 | 22 | # test if .git is present 23 | if [ ! -d $CMAKE_SOURCE_DIR/.git ]; then 24 | git_is_present=0 25 | fi 26 | 27 | git_commit=`git rev-parse HEAD 2> /dev/null` 28 | if [ "$git_commit" == "" ]; then 29 | git_is_present=0 30 | fi 31 | 32 | if [ $git_is_present -eq 1 ]; then 33 | git_branch=`git rev-parse --abbrev-ref HEAD 2> /dev/null` 34 | echo " > Found a git branch: $git_branch" 35 | echo " > Found a git commit: $git_commit" 36 | git_date=`git show -s --format="%ci" $git_commit` 37 | echo " > Found a git date: $git_date" 38 | 39 | # erase any previous version file 40 | \rm -f $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 41 | \touch $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 42 | echo "#ifndef _GIT_LOG_MMG_H" >> $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 43 | echo "#define _GIT_LOG_MMG_H" >> $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 44 | echo "#define MMG_GIT_BRANCH \"$git_branch\"" >> $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 45 | echo "#define MMG_GIT_COMMIT \"$git_commit\"" >> $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 46 | echo "#define MMG_GIT_DATE \"$git_date\"" >> $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 47 | echo "#endif" >> $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 48 | 49 | # diff 50 | diff=`diff $MMG_BINARY_DIR/$HEADER_FILE"_tmp" "$MMG_BINARY_DIR/$HEADER_FILE"` 51 | if [ "$diff" != "" ]; then 52 | \cp $MMG_BINARY_DIR/$HEADER_FILE"_tmp" "$MMG_BINARY_DIR/$HEADER_FILE" 53 | fi 54 | 55 | # clean 56 | \rm -f $MMG_BINARY_DIR/$HEADER_FILE"_tmp" 57 | fi 58 | -------------------------------------------------------------------------------- /src/common/chrono_private.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef CHRONO_H 25 | #define CHRONO_H 26 | 27 | #include 28 | #include "mmgcommon_private.h" 29 | 30 | #ifndef MMG_POSIX 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | 37 | #include "mmg_core_export_private.h" 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #ifndef ON 44 | #define RESET 0 45 | #define ON 1 46 | #define OFF 2 47 | #endif 48 | 49 | #define BIG 1e6 50 | #define BIG1 1e-6 51 | #define TIMEMAX 12 52 | 53 | /** 54 | * \struct mytime 55 | * \brief Chrono object. 56 | * 57 | * mytime allow storage of chronograph informations. 58 | * 59 | */ 60 | typedef struct mytime { 61 | double gini,gend,gdif,uini,uend,udif,sini,send,sdif; 62 | #ifdef MMG_POSIX 63 | struct timeval rutim; 64 | struct rusage ru; 65 | #else 66 | HANDLE thisProcess; 67 | FILETIME ftIni, ftEnd, ftSys, ftUser; 68 | SYSTEMTIME stSys, stUser; 69 | LARGE_INTEGER frequency; 70 | LARGE_INTEGER rutim; 71 | #endif 72 | int call; 73 | } mytime; 74 | 75 | 76 | /* prototypes */ 77 | LIBMMG_CORE_EXPORT void chrono(int cmode,mytime *ptt); 78 | LIBMMG_CORE_EXPORT void tminit(mytime *t,int maxtim); 79 | LIBMMG_CORE_EXPORT void printim(double ,char *); 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/common/eigenv_private.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMGEIGENV_H 25 | #define MMGEIGENV_H 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #define MMG5_EPSD 1.e-30 32 | #define MMG5_EPS 1.e-06 33 | 34 | int MMG5_eigenv3d(int symmat,double *mat,double lambda[3],double v[3][3]); 35 | int MMG5_eigenv2d(int symmat,double *mat,double lambda[2],double v[2][2]); 36 | int MMG5_eigen2(double *mm,double *lambda,double vp[2][2]); 37 | extern int MMG5_eigensym(double m[3],double lambda[2],double vp[2][2]); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/common/librnbg_private.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | /** 24 | * \brief header file for the librnbg.c librnbg_s.c librnbg_3d.c files 25 | * \author Cedric Lachat (Inria/UBordeaux) 26 | * \version 5 27 | * \date 2013 28 | * \copyright GNU Lesser General Public License. 29 | */ 30 | 31 | #ifdef USE_SCOTCH 32 | 33 | #ifndef __RENUM__ 34 | #define __RENUM__ 35 | 36 | #include 37 | 38 | #define HASHPRIME 37 39 | 40 | #define STRINGIFY(x) #x 41 | #define TOSTRING(x) STRINGIFY(x) 42 | 43 | #define SCOTCH_5 (!strcmp(TOSTRING(SCOTCH_VERSION),"5.0") || \ 44 | !strcmp(TOSTRING(SCOTCH_VERSION),"5.1") || !strcmp(TOSTRING(SCOTCH_VERSION),"5")) 45 | 46 | #define SCOTCH_6 !strcmp(TOSTRING(SCOTCH_VERSION),"6") 47 | 48 | #define SCOTCH_7 !strcmp(TOSTRING(SCOTCH_VERSION),"7") 49 | 50 | #define CHECK_SCOTCH(t,m,e) if(0!=t){perror(m);return e;} 51 | 52 | int _SCOTCHintSort2asc1(SCOTCH_Num * sortPartTb, MMG5_int vertNbr); 53 | int MMG5_kPartBoxCompute(SCOTCH_Graph*, MMG5_int, MMG5_int, SCOTCH_Num*,MMG5_pMesh); 54 | void MMG5_swapNod(MMG5_pMesh,MMG5_pPoint, double*, MMG5_pSol,MMG5_int*, MMG5_int, MMG5_int, int); 55 | 56 | #endif /* __RENUM__ */ 57 | #endif 58 | -------------------------------------------------------------------------------- /src/common/mmg3.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * \brief common functions for lagrangian meshing. 26 | * \author Charles Dapogny (UPMC) 27 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 28 | * \author Pascal Frey (UPMC) 29 | * \author Algiane Froehly (Inria/UBordeaux) 30 | * \version 5 31 | * \copyright GNU Lesser General Public License. 32 | */ 33 | 34 | #include "mmgcommon_private.h" 35 | 36 | /** 37 | * \param mesh pointer to the mesh structure 38 | * \param disp pointer to the displacement field 39 | * \param lastt 0 if a movement is possible, pointer to the last tested fraction otherwise 40 | * \param shortmax maximal parameter t (MMG2D_SHORTMAX or MMG3D_SHORTMAX) 41 | * \param chkmovmesh function that has to be called to check motion validity 42 | * 43 | * \return the largest fraction t allowing a valid motion 44 | * 45 | * Generic function to compute the the largest fraction t that makes the motion 46 | * along disp valid. 47 | * 48 | */ 49 | short MMG5_dikmov ( MMG5_pMesh mesh,MMG5_pSol disp,short *lastt,short shortmax, 50 | MMG5_int chkmovmesh(MMG5_pMesh,MMG5_pSol,short,MMG5_int*) ) { 51 | int it,maxit; 52 | short t,tmin,tmax; 53 | int8_t ier; 54 | 55 | maxit = 200; 56 | it = 0; 57 | 58 | tmin = 0; 59 | tmax = shortmax; 60 | 61 | *lastt = 0; 62 | 63 | /* If full displacement can be achieved */ 64 | if ( !chkmovmesh(mesh,disp,tmax,NULL) ) 65 | return tmax; 66 | 67 | /* Else, find the largest displacement by dichotomy */ 68 | assert ( tmax > tmin && "t will be used uninitialized if we don't enter next loop"); 69 | 70 | while( tmin != tmax && it < maxit ) { 71 | t = (tmin+tmax)/2; 72 | 73 | /* Case that tmax = tmin +1 : check move with tmax */ 74 | if ( t == tmin ) { 75 | ier = chkmovmesh(mesh,disp,tmax,NULL); 76 | if ( !ier ) { 77 | return tmax; 78 | } 79 | else { 80 | if ( tmin==0 ) { 81 | *lastt = tmax; 82 | } 83 | return tmin; 84 | } 85 | } 86 | 87 | /* General case: check move with t */ 88 | ier = chkmovmesh(mesh,disp,t,NULL); 89 | if ( !ier ) { 90 | tmin = t; 91 | } 92 | else 93 | tmax = t; 94 | 95 | it++; 96 | } 97 | 98 | if ( tmin==0 ) { 99 | *lastt=t; 100 | } 101 | 102 | return tmin; 103 | } 104 | 105 | /** 106 | * \param mesh pointer to the mesh structure 107 | * \param disp pointer to the displacement field 108 | * 109 | * \return 1 if success, 0 if fail. 110 | * 111 | * For debugging purposes: save displacement field. 112 | * 113 | */ 114 | int MMG5_saveDisp(MMG5_pMesh mesh,MMG5_pSol disp) { 115 | FILE *out; 116 | MMG5_int k; 117 | char data[256],*ptr; 118 | 119 | strcpy(data,disp->namein); 120 | ptr = strstr(data,".sol"); 121 | *ptr = '\0'; 122 | strcat(data,".o.disp.sol"); 123 | 124 | out = fopen(data,"w"); 125 | 126 | fprintf(out,"MeshVersionFormatted 1\n\nDimension\n%d\n\n",disp->dim); 127 | fprintf(out,"SolAtVertices\n%"MMG5_PRId"\n 1 2\n",disp->np); 128 | 129 | /* Print solutions */ 130 | for(k=1; k<= disp->np; k++) { 131 | int i; 132 | for ( i=0; idim; ++i ) { 133 | fprintf(out," %f",disp->m[mesh->dim*k+i]); 134 | } 135 | fprintf(out,"\n"); 136 | } 137 | 138 | fprintf(out,"\nEnd"); 139 | fclose(out); 140 | 141 | return 1; 142 | } 143 | -------------------------------------------------------------------------------- /src/common/mmg_core_export_private.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMG_CORE_EXPORT_H 25 | #define MMG_CORE_EXPORT_H 26 | 27 | #include "mmg_export.h" 28 | #if defined(libmmg_so_EXPORTS) || defined(libmmgs_so_EXPORTS) || defined(libmmg2d_so_EXPORTS) || defined(libmmg3d_so_EXPORTS) 29 | # define LIBMMG_CORE_EXPORT MMG_DECL_EXPORT 30 | #else 31 | # define LIBMMG_CORE_EXPORT MMG_DECL_IMPORT 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/common/mmg_export.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================ = 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright(c) Bx INP / CNRS / Inria / UBordeaux / UPMC, 2004 - 5 | ** 6 | ** mmg is free software : you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE.See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg(in 18 | ** files COPYING.LESSER and COPYING).If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================ = 22 | */ 23 | 24 | #ifndef MMG_EXPORT_H 25 | #define MMG_EXPORT_H 26 | 27 | #include "mmg/common/mmgcmakedefines.h" 28 | 29 | #if(MMG_DYN_LIB) 30 | # if defined(_WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__) 31 | # define MMG_DECL_EXPORT __declspec(dllexport) 32 | # define MMG_DECL_IMPORT __declspec(dllimport) 33 | # define MMG_DECL_HIDDEN 34 | # elif(__GNUC__ >= 4) 35 | # define MMG_DECL_EXPORT __attribute__((visibility("default"))) 36 | # define MMG_DECL_IMPORT __attribute__((visibility("default"))) 37 | # define MMG_DECL_HIDDEN __attribute__((visibility("hidden"))) 38 | # endif 39 | #endif 40 | 41 | #if !defined(MMG_DECL_EXPORT) 42 | # define MMG_DECL_EXPORT 43 | # define MMG_DECL_IMPORT 44 | # define MMG_DECL_HIDDEN 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/common/mmgcmakedefines.h.in: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMGCMAKEDEFINE_H 25 | #define MMGCMAKEDEFINE_H 26 | 27 | /* inttypes.h is needed to handle prints of MMG5_int using PRId32 and PRId64 macros */ 28 | #include 29 | 30 | @DEF_POSIX@ 31 | @DEF_GNU@ 32 | 33 | @DEF_MMG5_INT@ /*!< Integer type for C */ 34 | 35 | @DEF_MMG5_INTMAX@ /*!< INT_MAX or LONG_MAX depending on MMG5_INT size */ 36 | 37 | @DEF_MMG5_PRId@ /*!< Printing format for MMG5_int type */ 38 | 39 | @DEF_MMG_SWPBIN@ /*!< MMG5_swapbin function for MMG5_int */ 40 | 41 | @DEF_MMG_ABS@ /*!< Abs function for MMG5_int */ 42 | 43 | #cmakedefine USE_POINTMAP /*!< Flag to enable and export the pointmap used */ 44 | #cmakedefine01 MMG_DYN_LIB 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/common/mmgcmakedefinesf.h.in: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMGCMAKEDEFINEF_H 25 | #define MMGCMAKEDEFINEF_H 26 | 27 | @DEF_MMG5F_INT@ /*!< Integer type for fortran */ 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/common/mmgexterns.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #include "mmgcommon_private.h" 25 | 26 | #define MMG_EXTERN 27 | #define MMG_ASSIGN_NULL =NULL 28 | 29 | #include "mmgexterns_private.h" 30 | -------------------------------------------------------------------------------- /src/common/mmgexterns_private.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMGEXTERNS_H 25 | #define MMGEXTERNS_H 26 | 27 | #include "mmgcommon_private.h" 28 | 29 | #ifndef MMG_EXTERN 30 | #define MMG_EXTERN extern 31 | #define MMG_ASSIGN_NULL 32 | #endif 33 | 34 | FUNCTION_POINTER ( int (*MMG5_chkmsh)(MMG5_pMesh,int,MMG5_int) ); 35 | FUNCTION_POINTER ( int (*MMG5_bezierCP)(MMG5_pMesh ,MMG5_Tria *,MMG5_pBezier ,int8_t ) ); 36 | FUNCTION_POINTER ( double (*MMG5_lenSurfEdg)(MMG5_pMesh mesh,MMG5_pSol sol ,MMG5_int ,MMG5_int, int8_t ) ); 37 | FUNCTION_POINTER ( MMG5_int (*MMG5_indElt)(MMG5_pMesh mesh,MMG5_int kel) ); 38 | FUNCTION_POINTER ( MMG5_int (*MMG5_indPt)(MMG5_pMesh mesh,MMG5_int kp) ); 39 | FUNCTION_POINTER ( MMG5_int (*MMG5_grad2met_ani)(MMG5_pMesh,MMG5_pSol,MMG5_pTria,MMG5_int,MMG5_int) ); 40 | FUNCTION_POINTER ( int (*MMG5_grad2metreq_ani)(MMG5_pMesh,MMG5_pSol,MMG5_pTria,MMG5_int,MMG5_int) ); 41 | FUNCTION_POINTER ( int (*MMG5_compute_meanMetricAtMarkedPoints)( MMG5_pMesh,MMG5_pSol) ); 42 | FUNCTION_POINTER ( int (*MMG5_solTruncature_ani)(MMG5_pMesh mesh, MMG5_pSol met) ); 43 | FUNCTION_POINTER ( int (*MMG5_resetRef)(MMG5_pMesh) ); 44 | FUNCTION_POINTER ( int (*MMG5_setref)(MMG5_pMesh,MMG5_pSol) ); 45 | FUNCTION_POINTER ( int (*MMG5_snpval)(MMG5_pMesh,MMG5_pSol)); 46 | 47 | #ifdef USE_SCOTCH 48 | FUNCTION_POINTER ( int (*MMG5_renumbering)(int,MMG5_pMesh,MMG5_pSol,MMG5_pSol,MMG5_int*) ); 49 | #endif 50 | 51 | #undef MMG_EXTERN 52 | #undef MMG_ASSIGN_NULL 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/common/mmgversion.h.in: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- . 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | #ifndef _WIN32 24 | #include "mmg/common/git_log_mmg.h" 25 | #endif 26 | 27 | #ifndef MMGVERSION_H 28 | #define MMGVERSION_H 29 | 30 | #define MMG_VERSION_RELEASE "@CMAKE_RELEASE_VERSION@" 31 | #define MMG_VERSION_MAJOR @CMAKE_RELEASE_VERSION_MAJOR@ 32 | #define MMG_VERSION_MINOR @CMAKE_RELEASE_VERSION_MINOR@ 33 | #define MMG_VERSION_PATCH @CMAKE_RELEASE_VERSION_PATCH@ 34 | #define MMG_RELEASE_DATE "@CMAKE_RELEASE_DATE@" 35 | 36 | #define MMG_COPYRIGHT "Copyright (c) Bdx INP/CNRS/Inria/UPMC, 2004-" 37 | 38 | #define MMG_VERSION_EQ(MAJOR,MINOR) \ 39 | ((MMG_VERSION_MAJOR == (MAJOR)) && (MMG_VERSION_MINOR == (MINOR))) 40 | 41 | #define MMG_VERSION_ MMG_VERSION_EQ 42 | 43 | #define MMG_VERSION_LT(MAJOR,MINOR) \ 44 | (MMG_VERSION_MAJOR < (MAJOR) || (MMG_VERSION_MAJOR == (MAJOR) && \ 45 | (MMG_VERSION_MINOR < (MINOR) ))) 46 | 47 | #define MMG_VERSION_LE(MAJOR,MINOR) \ 48 | (MMG_VERSION_LT(MAJOR,MINOR) || MMG_VERSION_EQ(MAJOR,MINOR)) 49 | 50 | #define MMG_VERSION_GT(MAJOR,MINOR) (0 == MMG_VERSION_LE(MAJOR,MINOR)) 51 | 52 | #define MMG_VERSION_GE(MAJOR,MINOR) (0 == MMG_VERSION_LT(MAJOR,MINOR)) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/mmg/libmmg.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /* 25 | * WARNING: To keep the genheader program working, don't break line between an enum 26 | * name and the opening brace (it creates errors under windows) 27 | */ 28 | 29 | /* The following comment block defines the Doxygen group with label API, which 30 | * includes 31 | * mmg3d/libmmg3d.h 32 | * mmg2d/libmmg2.h 33 | * mmgs/libmmg2d.h 34 | * and others 35 | * with the aim to generate a central index into the API documentation. 36 | */ 37 | 38 | /** 39 | * \defgroup API Application Programming Interface 40 | * 41 | * Mmg comes with three application programming interfaces (APIs), one 42 | * corresponding to each of the command-line programs. In total there are over 43 | * 360 API functions. You can find their declarations and descriptions in the 44 | * files listed above. 45 | * 46 | * Examples showing how to use these functions can be found under the "Related 47 | * Pages" tab. 48 | * 49 | */ 50 | 51 | /** 52 | * \file common/libmmg.h 53 | * \brief Wrapper for include files for the mmg library. 54 | * \author Algiane Froehly (Inria / IMB, Université de Bordeaux) 55 | * \author Mark Potse (IMB, Université de Bordeaux) 56 | * \version 5 57 | * \copyright GNU Lesser General Public License. 58 | */ 59 | 60 | #ifndef MMGLIB_H 61 | #define MMGLIB_H 62 | 63 | #include "mmg/mmg2d/libmmg2d.h" 64 | #include "mmg/mmgs/libmmgs.h" 65 | #include "mmg/mmg3d/libmmg3d.h" 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/mmg/libmmgf.h: -------------------------------------------------------------------------------- 1 | !/* ============================================================================= 2 | !** This file is part of the mmg software package for the tetrahedral 3 | !** mesh modification. 4 | !** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | !** 6 | !** mmg is free software: you can redistribute it and/or modify it 7 | !** under the terms of the GNU Lesser General Public License as published 8 | !** by the Free Software Foundation, either version 3 of the License, or 9 | !** (at your option) any later version. 10 | !** 11 | !** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | !** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | !** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | !** License for more details. 15 | !** 16 | !** You should have received a copy of the GNU Lesser General Public 17 | !** License and of the GNU General Public License along with mmg (in 18 | !** files COPYING.LESSER and COPYING). If not, see 19 | !** . Please read their terms carefully and 20 | !** use this copy of the mmg distribution only if you accept them. 21 | !** ============================================================================= 22 | !*/ 23 | ! 24 | !/** 25 | ! * \file common/libmmgf.h 26 | ! * \brief Wrapper for include files for the mmg library. 27 | ! * \author Algiane Froehly (Inria / IMB, Université de Bordeaux) 28 | ! * \version 5 29 | ! * \date 01 2014 30 | ! * \copyright GNU Lesser General Public License. 31 | ! * \warning To keep the genheader working, don't break line between the enum 32 | ! * name and the opening brace (it creates errors under windows) 33 | ! */ 34 | 35 | #ifndef MMGFLIB_H 36 | #define MMGFLIB_H 37 | 38 | #include "mmg/mmg2d/libmmg2df.h" 39 | #include "mmg/mmgs/libmmgsf.h" 40 | #include "mmg/mmg3d/libmmg3df.h" 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/mmg2d/cenrad_2d.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | /** 24 | * \file mmg2d/cenrad_2d.c 25 | * \brief Compute radius and center of circumscribing circle to the element. 26 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 27 | * \date 2015 28 | * \copyright GNU Lesser General Public License. 29 | */ 30 | 31 | #include "libmmg2d_private.h" 32 | /** 33 | * \param mesh Pointer toward the mesh structure. 34 | * \param *ct coordinates of vertices of the element. 35 | * \param *c center of circumscribing circle to the element. 36 | * \param *rad radius of circumscribing circle to the element. 37 | * \return 0 if failed, 1 otherwise. 38 | * 39 | * Compute radius and center of circumscribing circle to the element. 40 | * 41 | */ 42 | int MMG2D_cenrad_iso(MMG5_pMesh mesh,double *ct,double *c,double *rad) { 43 | double dd,ux,uy,n1[2],n2[2],*c1,*c2,*c3,pl1,pl2; 44 | double cc1,cc2; 45 | 46 | c1 = &ct[0]; 47 | c2 = &ct[2]; 48 | c3 = &ct[4]; 49 | 50 | ux = c3[0] - c1[0]; 51 | uy = c3[1] - c1[1]; 52 | 53 | dd = 1.0 / sqrt(ux*ux + uy*uy); 54 | n1[0] = ux*dd; 55 | n1[1] = uy*dd; 56 | 57 | /* droite passant par le milieu de c1c3 */ 58 | pl1 = 0.5*(n1[0]*(c3[0]+c1[0])+ n1[1]*(c3[1]+c1[1])) ; 59 | 60 | ux = c3[0] - c2[0]; 61 | uy = c3[1] - c2[1]; 62 | 63 | dd = 1.0 / sqrt(ux*ux + uy*uy); 64 | n2[0] = ux*dd; 65 | n2[1] = uy*dd; 66 | pl2 = 0.5*(n2[0]*(c3[0]+c2[0])+ n2[1]*(c3[1]+c2[1])); 67 | 68 | /* center = intersection of 3 mediatrice */ 69 | dd = n1[0]*n2[1] - n2[0]*n1[1] ; 70 | if(fabs((dd))<1e-12) return 0; 71 | dd = 1./dd; 72 | 73 | cc1 = n2[1]*pl1 - n1[1]*pl2; 74 | cc2 = -n2[0]*pl1 + n1[0]*pl2; 75 | 76 | c[0] = dd * cc1; 77 | c[1] = dd * cc2; 78 | 79 | /* radius (squared) */ 80 | *rad = (c[0] - c1[0]) * (c[0] - c1[0]) \ 81 | + (c[1] - c1[1]) * (c[1] - c1[1]); 82 | 83 | /* printf("check rad %e -- %e %e\n",*rad, (c[0] - c2[0]) * (c[0] - c2[0]) \ */ 84 | /* + (c[1] - c2[1]) * (c[1] - c2[1]), (c[0] - c3[0]) * (c[0] - c3[0]) \ */ 85 | /* + (c[1] - c3[1]) * (c[1] - c3[1])); */ 86 | 87 | return 1; 88 | } 89 | -------------------------------------------------------------------------------- /src/mmg2d/libmmg2df.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * \file mmg2d/libmmg2df.c 26 | * \brief Fortran API functions for MMG2D library. 27 | * \author Charles Dapogny (UPMC) 28 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 29 | * \author Pascal Frey (UPMC) 30 | * \author Algiane Froehly (Inria/UBordeaux) 31 | * \version 5 32 | * \date 01 2014 33 | * \copyright GNU Lesser General Public License. 34 | * \note Please, refer to the \ref mmg2d/liblibmmg2d_private.h file for functions 35 | * documentation. 36 | * 37 | * Define the private Fortran API functions for MMG2D library 38 | * (incompatible functions with the main binary): adds function 39 | * definitions with upcase, underscore and double underscore to match 40 | * any fortran compiler. 41 | * 42 | */ 43 | 44 | #include "libmmg2d.h" 45 | #include "mmgcommon_private.h" 46 | 47 | /** 48 | * See \ref MMG2D_mmg2dlib function in \ref mmg2d/liblibmmg2d_private.h file. 49 | */ 50 | FORTRAN_NAME(MMG2D_MMG2DLIB,mmg2d_mmg2dlib,(MMG5_pMesh *mesh,MMG5_pSol *met 51 | ,int* retval),(mesh,met 52 | ,retval)){ 53 | 54 | *retval = MMG2D_mmg2dlib(*mesh,*met); 55 | 56 | return; 57 | } 58 | /** 59 | * See \ref MMG2D_mmg2dmesh function in \ref mmg2d/liblibmmg2d_private.h file. 60 | */ 61 | FORTRAN_NAME(MMG2D_MMG2DMESH,mmg2d_mmg2dmesh,(MMG5_pMesh *mesh,MMG5_pSol *met 62 | ,int* retval),(mesh,met 63 | ,retval)){ 64 | 65 | *retval = MMG2D_mmg2dmesh(*mesh,*met); 66 | 67 | return; 68 | } 69 | /** 70 | * See \ref MMG2D_mmg2dls function in \ref mmg2d/liblibmmg2d_private.h file. 71 | */ 72 | FORTRAN_NAME(MMG2D_MMG2DLS,mmg2d_mmg2dls,(MMG5_pMesh *mesh,MMG5_pSol *sol, 73 | MMG5_pSol *met,int* retval), 74 | (mesh,sol,met,retval)){ 75 | 76 | if ( met ) { 77 | *retval = MMG2D_mmg2dls(*mesh,*sol,*met); 78 | } 79 | else { 80 | *retval = MMG2D_mmg2dls(*mesh,*sol,NULL); 81 | } 82 | 83 | return; 84 | } 85 | /** 86 | * See \ref MMG2D_mmg2dmov function in \ref mmg2d/liblibmmg2d_private.h file. 87 | */ 88 | FORTRAN_NAME(MMG2D_MMG2DMOV,mmg2d_mmg2dmov,(MMG5_pMesh *mesh,MMG5_pSol *met,MMG5_pSol *disp 89 | ,int* retval),(mesh,met,disp 90 | ,retval)){ 91 | 92 | *retval = MMG2D_mmg2dmov(*mesh,*met,*disp); 93 | 94 | return; 95 | } 96 | -------------------------------------------------------------------------------- /src/mmg2d/mmg2d_export.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMG2D_EXPORT_H 25 | #define MMG2D_EXPORT_H 26 | 27 | #include "mmg/common/mmg_export.h" 28 | #if defined(libmmg_so_EXPORTS) || defined(libmmg2d_so_EXPORTS) 29 | # define LIBMMG2D_EXPORT MMG_DECL_EXPORT 30 | #else 31 | # define LIBMMG2D_EXPORT MMG_DECL_IMPORT 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/mmg2d/mmg2dexterns.c: -------------------------------------------------------------------------------- 1 | #include "libmmgtypes.h" 2 | #include "mmg2d_export.h" 3 | 4 | #define MMG_EXTERN 5 | #define MMG_ASSIGN_NULL =NULL 6 | 7 | #include "mmg2dexterns_private.h" 8 | 9 | LIBMMG2D_EXPORT int (*MMG2D_doSol)(MMG5_pMesh ,MMG5_pSol )=NULL; 10 | -------------------------------------------------------------------------------- /src/mmg2d/mmg2dexterns_private.h: -------------------------------------------------------------------------------- 1 | #ifndef MMG2DEXTERNS_H 2 | #define MMG2DEXTERNS_H 3 | 4 | #include "libmmgtypes.h" 5 | #include "mmgcommon_private.h" 6 | 7 | #ifndef MMG_EXTERN 8 | #define MMG_EXTERN extern 9 | #define MMG_ASSIGN_NULL 10 | #endif 11 | 12 | FUNCTION_POINTER ( int (*MMG2D_defsiz)(MMG5_pMesh ,MMG5_pSol ) ); 13 | FUNCTION_POINTER ( int (*MMG2D_intmet)(MMG5_pMesh ,MMG5_pSol ,MMG5_int ,int8_t ,MMG5_int ,double ) ); 14 | FUNCTION_POINTER ( double(*MMG2D_lencurv)(MMG5_pMesh ,MMG5_pSol ,MMG5_int ,MMG5_int ) ); 15 | FUNCTION_POINTER ( int (*MMG2D_gradsizreq)(MMG5_pMesh ,MMG5_pSol ) ); 16 | FUNCTION_POINTER ( double(*MMG2D_caltri)(MMG5_pMesh ,MMG5_pSol ,MMG5_pTria ) ); 17 | FUNCTION_POINTER ( int (*MMG2D_gradsiz)(MMG5_pMesh ,MMG5_pSol ) ); 18 | 19 | #undef MMG_EXTERN 20 | #undef MMG_ASSIGN_NULL 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/mmg2d/tools_2d.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | /** 24 | * \file mmg2d/tools_2d.c 25 | * \brief Various tools. 26 | * \author Charles Dapogny (UPMC) 27 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 28 | * \author Pascal Frey (UPMC) 29 | * \author Algiane Froehly (Inria/UBordeaux) 30 | * \version 5 31 | * \copyright GNU Lesser General Public License. 32 | */ 33 | 34 | #include "libmmg2d_private.h" 35 | 36 | /** 37 | * \param mesh pointer to the mesh structure. 38 | * \param kel index of the element in the unpacked mesh 39 | * 40 | * 41 | * \return 0 if fail, index of the element in packed numerotation otherwise. 42 | * 43 | * find the element index in packed numerotation 44 | * 45 | */ 46 | MMG5_int MMG2D_indElt(MMG5_pMesh mesh, MMG5_int kel) { 47 | MMG5_pTria pt; 48 | MMG5_int ne, k; 49 | 50 | ne = 0; 51 | for (k=1; k<=mesh->nt; k++) { 52 | pt = &mesh->tria[k]; 53 | if ( MG_EOK(pt) ) { 54 | ne++; 55 | if ( k == kel ) return ne; 56 | } 57 | } 58 | return 0; 59 | } 60 | 61 | /** 62 | * \param mesh pointer to the mesh structure. 63 | * \param kp index of the point in the unpacked mesh 64 | * 65 | * \return 0 if fail, index of the point in packed numerotation otherwise. 66 | * 67 | * find the point index in packed numerotation 68 | * 69 | */ 70 | MMG5_int MMG2D_indPt(MMG5_pMesh mesh, MMG5_int kp) { 71 | MMG5_pPoint ppt; 72 | MMG5_int np, k; 73 | 74 | np = 0; 75 | for (k=1; k<=mesh->np; k++) { 76 | ppt = &mesh->point[k]; 77 | if ( MG_VOK(ppt) ) { 78 | np++; 79 | if ( k == kp ) return np; 80 | } 81 | } 82 | return 0; 83 | } 84 | 85 | /** 86 | * \param mesh pointer to the mesh structure. 87 | * \param nsd index of subdomain to keep. 88 | * 89 | * Keep only subdomain of index \a nsd and remove other subdomains. 90 | * 91 | */ 92 | void MMG2D_keep_only1Subdomain ( MMG5_pMesh mesh,int nsd ) { 93 | 94 | if ( !nsd ) { 95 | return; 96 | } 97 | 98 | if ( mesh->info.imprim > 4 || mesh->info.ddebug ) { 99 | fprintf(stdout,"\n -- ONLY KEEP DOMAIN OF REF %d\n",nsd ); 100 | } 101 | 102 | MMG5_mark_verticesAsUnused ( mesh ); 103 | 104 | MMG5_keep_subdomainElts ( mesh, nsd, MMG2D_delElt ); 105 | 106 | MMG5_mark_usedVertices ( mesh,MMG2D_delPt ); 107 | 108 | return; 109 | } 110 | -------------------------------------------------------------------------------- /src/mmg3d/PRoctree_3d_private.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef PROCTREE_3D_H 25 | #define PROCTREE_3D_H 26 | 27 | #include "libmmgtypes.h" 28 | 29 | /** 30 | * PROctree cell: cellule for point region octree (to speed-up the research of 31 | * the closest point to another one). 32 | * 33 | */ 34 | typedef struct MMG3D_PROctree_s 35 | { 36 | struct MMG3D_PROctree_s* branches; /*!< pointer to the subtrees of the current PROctree */ 37 | MMG5_int* v; /*!< vertex index */ 38 | int nbVer; /*!< number of vertices in the sub tree */ 39 | int depth; /*!< sub tree depth */ 40 | } MMG3D_PROctree_s; 41 | 42 | /** 43 | * PROctree global structure (enriched by global variables) for point region 44 | * octree (to speed-up the research of the closest point to another one). 45 | */ 46 | typedef struct 47 | { 48 | int nv; /*!< Max number of points per PROctree cell */ 49 | int nc; /*!< Max number of cells listed per local search in the PROctree (-3)*/ 50 | MMG3D_PROctree_s* q0; /*!< Pointer toward the first PROctree cell */ 51 | } MMG3D_PROctree; 52 | typedef MMG3D_PROctree * MMG3D_pPROctree; 53 | 54 | void MMG3D_initPROctree_s( MMG3D_PROctree_s* q); 55 | int MMG3D_initPROctree(MMG5_pMesh,MMG3D_pPROctree* q, int nv); 56 | void MMG3D_freePROctree_s(MMG5_pMesh,MMG3D_PROctree_s* q, int nv); 57 | void MMG3D_freePROctree(MMG5_pMesh,MMG3D_PROctree** q); 58 | int MMG3D_isCellIncluded(double* cellCenter, double l, double* zoneCenter, double l0); 59 | void MMG3D_placeInListDouble(double*, double, int, int); 60 | void MMG3D_placeInListPROctree(MMG3D_PROctree_s**, MMG3D_PROctree_s*, int, int); 61 | int MMG3D_seekIndex (double* distList, double dist, int indexMin, int indexMax); 62 | int MMG3D_intersectRect(double *rectin, double *rectinout); 63 | int MMG3D_getListSquareRec(MMG3D_PROctree_s*,double*,double*, 64 | MMG3D_PROctree_s***,double*,double*,double, int, int, int*); 65 | int MMG3D_getListSquare(MMG5_pMesh,double*,MMG3D_PROctree*,double*,MMG3D_PROctree_s***); 66 | int MMG3D_addPROctreeRec(MMG5_pMesh,MMG3D_PROctree_s*,double*, const MMG5_int, int); 67 | int MMG3D_addPROctree(MMG5_pMesh mesh, MMG3D_PROctree* q, const MMG5_int no); 68 | int MMG3D_delPROctreeVertex(MMG5_pMesh,MMG3D_PROctree_s* q, MMG5_int no); 69 | int MMG3D_movePROctree(MMG5_pMesh, MMG3D_pPROctree,MMG5_int, double*, double*); 70 | void MMG3D_mergeBranchesRec(MMG3D_PROctree_s*, MMG3D_PROctree_s*, int, int , int*); 71 | void MMG3D_mergeBranches(MMG5_pMesh mesh,MMG3D_PROctree_s* q, int dim, int nv); 72 | int MMG3D_delPROctreeRec(MMG5_pMesh,MMG3D_PROctree_s*,double*, const MMG5_int,const int); 73 | int MMG3D_delPROctree(MMG5_pMesh mesh, MMG3D_pPROctree q, const int no); 74 | void MMG3D_printArbreDepth(MMG3D_PROctree_s* q, int depth, int nv, int dim); 75 | void MMG3D_printArbre(MMG3D_PROctree* q); 76 | void MMG3D_sizeArbreRec(MMG3D_PROctree_s* q, int nv, int dim, int*,int*); 77 | int* MMG3D_sizeArbre(MMG3D_PROctree* q, int dim); 78 | int MMG3D_PROctreein_iso(MMG5_pMesh,MMG5_pSol,MMG3D_pPROctree,MMG5_int,double); 79 | int MMG3D_PROctreein_ani(MMG5_pMesh,MMG5_pSol,MMG3D_pPROctree,MMG5_int,double); 80 | int64_t MMG3D_getPROctreeCoordinate(MMG3D_pPROctree q, double* ver, int dim); 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /src/mmg3d/libmmg3df.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * \file mmg3d/libmmg3df.c 26 | * \brief Fortran API functions for MMG3D library. 27 | * \author Charles Dapogny (UPMC) 28 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 29 | * \author Pascal Frey (UPMC) 30 | * \author Algiane Froehly (Inria/UBordeaux) 31 | * \version 5 32 | * \date 01 2014 33 | * \copyright GNU Lesser General Public License. 34 | * \note Please, refer to the \ref mmg3d/libmmg3d.h file for functions 35 | * documentation. 36 | * 37 | * Define the private Fortran API functions for MMG3D library 38 | * (incompatible functions with the main binary): adds function 39 | * definitions with upcase, underscore and double underscore to match 40 | * any fortran compiler. 41 | * 42 | */ 43 | 44 | #include "libmmg3d.h" 45 | #include "mmgcommon_private.h" 46 | 47 | /** 48 | * See \ref MMG3D_mmg3dlib function in \ref mmg3d/libmmg3d.h file. 49 | */ 50 | FORTRAN_NAME(MMG3D_MMG3DLIB,mmg3d_mmg3dlib,(MMG5_pMesh *mesh,MMG5_pSol *met, 51 | int* retval), 52 | (mesh,met,retval)){ 53 | 54 | *retval = MMG3D_mmg3dlib(*mesh,*met); 55 | 56 | return; 57 | } 58 | 59 | /** 60 | * See \ref MMG3D_mmg3dls function in \ref mmg3d/libmmg3d.h file. 61 | */ 62 | FORTRAN_NAME(MMG3D_MMG3DLS,mmg3d_mmg3dls,(MMG5_pMesh *mesh,MMG5_pSol *sol, 63 | MMG5_pSol *met,int* retval), 64 | (mesh,sol,met,retval)){ 65 | 66 | if ( met ) { 67 | *retval = MMG3D_mmg3dls(*mesh,*sol,*met); 68 | } 69 | else { 70 | *retval = MMG3D_mmg3dls(*mesh,*sol,NULL); 71 | } 72 | return; 73 | } 74 | 75 | /** 76 | * See \ref MMG3D_mmg3dmov function in \ref mmg3d/libmmg3d.h file. 77 | */ 78 | FORTRAN_NAME(MMG3D_MMG3DMOV,mmg3d_mmg3dmov,(MMG5_pMesh *mesh,MMG5_pSol *met 79 | ,MMG5_pSol *disp,int* retval), 80 | (mesh,met,disp,retval)){ 81 | 82 | *retval = MMG3D_mmg3dmov(*mesh,*met,*disp); 83 | 84 | return; 85 | } 86 | -------------------------------------------------------------------------------- /src/mmg3d/mmg3d_export.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMG3D_EXPORT_H 25 | #define MMG3D_EXPORT_H 26 | 27 | #include "mmg/common/mmg_export.h" 28 | #if defined(libmmg_so_EXPORTS) || defined(libmmg3d_so_EXPORTS) 29 | # define LIBMMG3D_EXPORT MMG_DECL_EXPORT 30 | #else 31 | # define LIBMMG3D_EXPORT MMG_DECL_IMPORT 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/mmg3d/mmg3dexterns.c: -------------------------------------------------------------------------------- 1 | #include "libmmg3d_private.h" 2 | #include "mmg3d_export.h" 3 | 4 | 5 | #define MMG_EXTERN 6 | #define MMG_ASSIGN_NULL =NULL 7 | 8 | #include "mmg3dexterns_private.h" 9 | 10 | LIBMMG3D_EXPORT double (*MMG3D_lenedgCoor)(double *ca,double *cb,double *sa,double *sb)=NULL; 11 | LIBMMG3D_EXPORT int (*MMG3D_doSol)(MMG5_pMesh mesh,MMG5_pSol met)=NULL; 12 | -------------------------------------------------------------------------------- /src/mmg3d/mmg3dexterns_private.h: -------------------------------------------------------------------------------- 1 | #ifndef MMG3DEXTERNS_H 2 | #define MMG3DEXTERNS_H 3 | 4 | #include "libmmgtypes.h" 5 | #include "PRoctree_3d_private.h" 6 | #include "mmgcommon_private.h" 7 | 8 | #ifndef MMG_EXTERN 9 | #define MMG_EXTERN extern 10 | #define MMG_ASSIGN_NULL 11 | #endif 12 | 13 | FUNCTION_POINTER ( double (*MMG5_lenedg)(MMG5_pMesh ,MMG5_pSol ,int, MMG5_pTetra ) ); 14 | FUNCTION_POINTER ( double (*MMG5_lenedgspl)(MMG5_pMesh ,MMG5_pSol ,int, MMG5_pTetra ) ); 15 | FUNCTION_POINTER ( double (*MMG5_caltet)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_pTetra pt) ); 16 | FUNCTION_POINTER ( double (*MMG5_caltri)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_pTria ptt) ); 17 | FUNCTION_POINTER ( int (*MMG3D_defsiz)(MMG5_pMesh ,MMG5_pSol ) ); 18 | FUNCTION_POINTER ( int (*MMG3D_gradsiz)(MMG5_pMesh ,MMG5_pSol ) ); 19 | FUNCTION_POINTER ( int (*MMG3D_gradsizreq)(MMG5_pMesh ,MMG5_pSol ) ); 20 | FUNCTION_POINTER ( int (*MMG5_intmet)(MMG5_pMesh,MMG5_pSol,MMG5_int,int8_t,MMG5_int, double) ); 21 | FUNCTION_POINTER ( int (*MMG5_interp4bar)(MMG5_pMesh,MMG5_pSol,MMG5_int,MMG5_int,double *) ); 22 | FUNCTION_POINTER ( int (*MMG5_movintpt)(MMG5_pMesh ,MMG5_pSol, MMG3D_pPROctree ,int64_t *, int , int ) ); 23 | FUNCTION_POINTER ( int (*MMG5_movbdyregpt)(MMG5_pMesh, MMG5_pSol, MMG3D_pPROctree ,int64_t*, int, MMG5_int*, int, int ,int) ); 24 | FUNCTION_POINTER ( int (*MMG5_movbdyrefpt)(MMG5_pMesh, MMG5_pSol, MMG3D_pPROctree ,int64_t*, int, MMG5_int*, int ,int) ); 25 | FUNCTION_POINTER ( int (*MMG5_movbdynompt)(MMG5_pMesh, MMG5_pSol, MMG3D_pPROctree ,int64_t*, int, MMG5_int*, int ,int) ); 26 | FUNCTION_POINTER ( int (*MMG5_movbdyridpt)(MMG5_pMesh, MMG5_pSol, MMG3D_pPROctree ,int64_t*, int, MMG5_int*, int ,int) ); 27 | FUNCTION_POINTER ( int (*MMG5_cavity)(MMG5_pMesh ,MMG5_pSol ,MMG5_int ,int ,int64_t *,int ,double) ); 28 | FUNCTION_POINTER ( int (*MMG3D_PROctreein)(MMG5_pMesh ,MMG5_pSol ,MMG3D_pPROctree ,MMG5_int,double ) ); 29 | FUNCTION_POINTER ( int (*MMG3D_resetRef)(MMG5_pMesh) ); 30 | FUNCTION_POINTER ( int (*MMG3D_setref)(MMG5_pMesh,MMG5_pSol) ); 31 | FUNCTION_POINTER ( int (*MMG3D_snpval)(MMG5_pMesh,MMG5_pSol) ); 32 | FUNCTION_POINTER ( int (*MMG3D_cuttet)(MMG5_pMesh,MMG5_pSol,MMG5_pSol) ); 33 | 34 | #undef MMG_EXTERN 35 | #undef MMG_ASSIGN_NULL 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/mmgs/gentools_s.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * \file mmgs/gentools_s.c 26 | * \brief Generic algebraic and algorithmic tools. 27 | * \author Charles Dapogny (UPMC) 28 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 29 | * \author Pascal Frey (UPMC) 30 | * \author Algiane Froehly (Inria/UBordeaux) 31 | * \version 5 32 | * \copyright GNU Lesser General Public License. 33 | */ 34 | 35 | #include "libmmgs_private.h" 36 | 37 | 38 | /* Delete all triangle references in mesh */ 39 | int delref(MMG5_pMesh mesh) { 40 | MMG5_pTria pt; 41 | MMG5_int k; 42 | 43 | for(k=1; k<=mesh->nt; k++) { 44 | pt = &mesh->tria[k]; 45 | pt->ref = 0; 46 | } 47 | 48 | return 1; 49 | } 50 | 51 | /** 52 | * \param mesh pointer to the mesh 53 | * \param start index of the tetra from which we start 54 | * \param ref reference to set 55 | * \param putreq 1 if boundary edges must be set to required 56 | * 57 | * \return 1 if success, 0 if fail 58 | * 59 | * Start from triangle start, and pile up triangles by adjacency, till a GEO or 60 | * REF curve is met ; pass all references of travelled faces to ref ; putreq = 1 61 | * if boundary edges met must be set to MG_REQ, 0 otherwise. 62 | * 63 | */ 64 | int setref(MMG5_pMesh mesh,MMG5_int start,MMG5_int ref,int putreq) { 65 | MMG5_pTria pt,pt1; 66 | MMG5_int base,*list,*adja,cur,k,iel,jel; 67 | int ilist; 68 | int8_t j,voy; 69 | 70 | ilist = cur = 0; 71 | MMG5_SAFE_CALLOC(list,mesh->nt+1,MMG5_int,return 0); 72 | base = ++mesh->base; 73 | 74 | /* Pile up triangles from start, till a GEO boundary is met */ 75 | pt = &mesh->tria[start]; 76 | list[ilist] = start; 77 | ilist++; 78 | assert( ilist <= mesh->nt ); 79 | pt->flag = base; 80 | 81 | do { 82 | iel = list[cur]; 83 | pt = &mesh->tria[iel]; 84 | adja = &mesh->adja[3*(iel-1)+1]; 85 | 86 | for(j=0; j<3; j++) { 87 | if( MG_EDG(pt->tag[j]) ) { 88 | if( putreq ) { 89 | pt->tag[j] |= MG_REQ; 90 | jel = adja[j] / 3; 91 | voy = adja[j] % 3; 92 | if( !jel ) continue; 93 | pt1 = &mesh->tria[jel]; 94 | pt1->tag[voy] |= MG_REQ; 95 | } 96 | continue; 97 | } 98 | jel = adja[j] / 3; 99 | assert(jel); 100 | pt1 = &mesh->tria[jel]; 101 | if ( pt1->flag == base ) continue; 102 | 103 | list[ilist] = jel; 104 | ilist++; 105 | assert( ilist <= mesh->nt ); 106 | pt1->flag = base; 107 | } 108 | cur++; 109 | } 110 | while( cur < ilist ); 111 | 112 | /* Set all references of triangles of list to ref */ 113 | for (k=0; ktria[iel]; 116 | pt->ref = ref; 117 | } 118 | MMG5_SAFE_FREE(list); 119 | return 1; 120 | } 121 | 122 | /** find the element number in packed numerotation */ 123 | MMG5_int MMGS_indElt(MMG5_pMesh mesh, MMG5_int kel) { 124 | MMG5_pTria pt; 125 | MMG5_int ne, k; 126 | 127 | ne = 0; 128 | for (k=1; k<=mesh->nt; k++) { 129 | pt = &mesh->tria[k]; 130 | if ( MG_EOK(pt) ) { 131 | ne++; 132 | if ( k == kel ) return ne; 133 | } 134 | } 135 | return 0; 136 | } 137 | 138 | /** find the point number in packed numerotation */ 139 | MMG5_int MMGS_indPt(MMG5_pMesh mesh, MMG5_int kp) { 140 | MMG5_pPoint ppt; 141 | MMG5_int np, k; 142 | 143 | np = 0; 144 | for (k=1; k<=mesh->np; k++) { 145 | ppt = &mesh->point[k]; 146 | if ( MG_VOK(ppt) ) { 147 | np++; 148 | if ( k == kp ) return np; 149 | } 150 | } 151 | return 0; 152 | } 153 | 154 | /** 155 | * \param mesh pointer to the mesh structure. 156 | * \param nsd index of subdomain to keep. 157 | * 158 | * Keep only subdomain of index \a nsd and remove other subdomains. 159 | * 160 | */ 161 | void MMGS_keep_only1Subdomain ( MMG5_pMesh mesh,MMG5_int nsd ) { 162 | 163 | if ( !nsd ) { 164 | return; 165 | } 166 | 167 | if ( mesh->info.imprim > 4 || mesh->info.ddebug ) { 168 | fprintf(stdout,"\n -- ONLY KEEP DOMAIN OF REF %"MMG5_PRId"\n",nsd ); 169 | } 170 | 171 | MMG5_mark_verticesAsUnused ( mesh ); 172 | 173 | MMG5_keep_subdomainElts ( mesh, nsd, MMGS_delElt ); 174 | 175 | MMG5_mark_usedVertices ( mesh,MMGS_delPt ); 176 | 177 | return; 178 | } 179 | -------------------------------------------------------------------------------- /src/mmgs/libmmgsf.c: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | /** 25 | * \file mmgs/libmmgsf.c 26 | * \brief Fortran API functions for MMGS library. 27 | * \author Charles Dapogny (UPMC) 28 | * \author Cécile Dobrzynski (Bx INP/Inria/UBordeaux) 29 | * \author Pascal Frey (UPMC) 30 | * \author Algiane Froehly (Inria/UBordeaux) 31 | * \version 5 32 | * \date 01 2014 33 | * \copyright GNU Lesser General Public License. 34 | * \note Please, refer to the \ref mmgs/libmmgs.h file for functions 35 | * documentation. 36 | * 37 | * Define the private Fortran API functions for MMGS library 38 | * (incompatible functions with the main binary): adds function 39 | * definitions with upcase, underscore and double underscore to match 40 | * any fortran compiler. 41 | * 42 | */ 43 | 44 | #include "libmmgs.h" 45 | #include "mmgcommon_private.h" 46 | 47 | /** 48 | * See \ref MMGS_mmgslib function in \ref mmgs/libmmgs.h file. 49 | */ 50 | FORTRAN_NAME(MMGS_MMGSLIB,mmgs_mmgslib,(MMG5_pMesh *mesh,MMG5_pSol *met, 51 | int* retval), 52 | (mesh,met,retval)){ 53 | 54 | *retval = MMGS_mmgslib(*mesh,*met); 55 | 56 | return; 57 | } 58 | 59 | /** 60 | * See \ref MMGS_mmgsls function in \ref mmgs/libmmgs.h file. 61 | */ 62 | FORTRAN_NAME(MMGS_MMGSLS,mmgs_mmgsls,(MMG5_pMesh *mesh,MMG5_pSol *sol, 63 | MMG5_pSol *met,int* retval), 64 | (mesh,sol,met,retval)){ 65 | 66 | if ( met ) { 67 | *retval = MMGS_mmgsls(*mesh,*sol,*met); 68 | } 69 | else { 70 | *retval = MMGS_mmgsls(*mesh,*sol,NULL); 71 | } 72 | 73 | return; 74 | } 75 | -------------------------------------------------------------------------------- /src/mmgs/mmgs_export.h: -------------------------------------------------------------------------------- 1 | /* ============================================================================= 2 | ** This file is part of the mmg software package for the tetrahedral 3 | ** mesh modification. 4 | ** Copyright (c) Bx INP/CNRS/Inria/UBordeaux/UPMC, 2004- 5 | ** 6 | ** mmg is free software: you can redistribute it and/or modify it 7 | ** under the terms of the GNU Lesser General Public License as published 8 | ** by the Free Software Foundation, either version 3 of the License, or 9 | ** (at your option) any later version. 10 | ** 11 | ** mmg is distributed in the hope that it will be useful, but WITHOUT 12 | ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ** License for more details. 15 | ** 16 | ** You should have received a copy of the GNU Lesser General Public 17 | ** License and of the GNU General Public License along with mmg (in 18 | ** files COPYING.LESSER and COPYING). If not, see 19 | ** . Please read their terms carefully and 20 | ** use this copy of the mmg distribution only if you accept them. 21 | ** ============================================================================= 22 | */ 23 | 24 | #ifndef MMGS_EXPORT_H 25 | #define MMGS_EXPORT_H 26 | 27 | #include "mmg/common/mmg_export.h" 28 | #if defined(libmmg_so_EXPORTS) || defined(libmmgs_so_EXPORTS) 29 | # define LIBMMGS_EXPORT MMG_DECL_EXPORT 30 | #else 31 | # define LIBMMGS_EXPORT MMG_DECL_IMPORT 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/mmgs/mmgsexterns.c: -------------------------------------------------------------------------------- 1 | #include "libmmgtypes.h" 2 | #include "mmgs_export.h" 3 | 4 | #define MMG_EXTERN 5 | #define MMG_ASSIGN_NULL =NULL 6 | 7 | #include "mmgsexterns_private.h" 8 | 9 | LIBMMGS_EXPORT int (*MMGS_doSol)(MMG5_pMesh mesh,MMG5_pSol met)=NULL; 10 | -------------------------------------------------------------------------------- /src/mmgs/mmgsexterns_private.h: -------------------------------------------------------------------------------- 1 | #ifndef MMGSEXTERNS_H 2 | #define MMGSEXTERNS_H 3 | 4 | #include "libmmgtypes.h" 5 | #include "mmgcommon_private.h" 6 | 7 | #ifndef MMG_EXTERN 8 | #define MMG_EXTERN extern 9 | #define MMG_ASSIGN_NULL 10 | #endif 11 | 12 | FUNCTION_POINTER ( double (*MMG5_calelt)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_pTria ptt) ); 13 | FUNCTION_POINTER ( int (*MMGS_defsiz)(MMG5_pMesh mesh,MMG5_pSol met) ); 14 | FUNCTION_POINTER ( int (*MMGS_gradsiz)(MMG5_pMesh mesh,MMG5_pSol met) ); 15 | FUNCTION_POINTER ( int (*MMGS_gradsizreq)(MMG5_pMesh mesh,MMG5_pSol met) ); 16 | FUNCTION_POINTER ( int (*intmet)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,int8_t i,MMG5_int ip,double s) ); 17 | FUNCTION_POINTER ( int (*movintpt)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int *list,int ilist) ); 18 | FUNCTION_POINTER ( int (*movridpt)(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int *list,int ilist) ); 19 | 20 | #undef MMG_EXTERN 21 | #undef MMG_ASSIGN_NULL 22 | 23 | #endif 24 | --------------------------------------------------------------------------------