Renaming functions and files + minor corrections in runner_main to detect what to do
This commit is contained in:
parent
2e0b7c8b58
commit
c59a01e4ce
@ -93,9 +93,8 @@ SET(NETGENEngine_HEADERS
|
|||||||
NETGENPlugin_Mesher.hxx
|
NETGENPlugin_Mesher.hxx
|
||||||
NETGENPlugin_Remesher_2D.hxx
|
NETGENPlugin_Remesher_2D.hxx
|
||||||
NETGENPlugin_Defs.hxx
|
NETGENPlugin_Defs.hxx
|
||||||
NETGENPlugin_Provider.hxx
|
NETGENPlugin_DriverParam.hxx
|
||||||
netgen_param.hxx
|
NETGENPlugin_Runner.hxx
|
||||||
netgen_mesher.hxx
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- sources ---
|
# --- sources ---
|
||||||
@ -123,12 +122,12 @@ SET(NETGENEngine_SOURCES
|
|||||||
NETGENPlugin_SimpleHypothesis_3D_i.cxx
|
NETGENPlugin_SimpleHypothesis_3D_i.cxx
|
||||||
NETGENPlugin_Remesher_2D.cxx
|
NETGENPlugin_Remesher_2D.cxx
|
||||||
NETGENPlugin_i.cxx
|
NETGENPlugin_i.cxx
|
||||||
netgen_mesher.cxx
|
NETGENPlugin_Runner.cxx
|
||||||
netgen_param.cxx
|
NETGENPlugin_DriverParam.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(Run_Mesher_SOURCES
|
SET(NetgenRunner_SOURCES
|
||||||
run_mesher.cxx
|
NETGENPlugin_Runner_main.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- scripts ---
|
# --- scripts ---
|
||||||
@ -145,9 +144,9 @@ ADD_LIBRARY(NETGENEngine ${NETGENEngine_SOURCES})
|
|||||||
TARGET_LINK_LIBRARIES(NETGENEngine ${_link_LIBRARIES} )
|
TARGET_LINK_LIBRARIES(NETGENEngine ${_link_LIBRARIES} )
|
||||||
INSTALL(TARGETS NETGENEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
|
INSTALL(TARGETS NETGENEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
|
||||||
|
|
||||||
ADD_EXECUTABLE(run_mesher ${Run_Mesher_SOURCES})
|
ADD_EXECUTABLE(NETGENPlugin_Runner ${NetgenRunner_SOURCES})
|
||||||
TARGET_LINK_LIBRARIES(run_mesher ${_link_LIBRARIES} NETGENEngine )
|
TARGET_LINK_LIBRARIES(NETGENPlugin_Runner ${_link_LIBRARIES} NETGENEngine )
|
||||||
INSTALL(TARGETS run_mesher EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
|
INSTALL(TARGETS NETGENPlugin_Runner EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
|
||||||
|
|
||||||
INSTALL(FILES ${NETGENEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
|
INSTALL(FILES ${NETGENEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
|
||||||
// File : netgen_param.hxx
|
// File : NETGENPlugin_DriverParam.hxx
|
||||||
// Author : Yoann AUDOUIN, EDF
|
// Author : Yoann AUDOUIN, EDF
|
||||||
// Module : SMESH
|
// Module : NETGEN
|
||||||
//
|
//
|
||||||
#include "netgen_param.hxx"
|
#include "NETGENPlugin_DriverParam.hxx"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
*
|
*
|
||||||
* @param aParams The object to display
|
* @param aParams The object to display
|
||||||
*/
|
*/
|
||||||
void print_netgen_params(netgen_params& aParams){
|
void printNetgenParams(netgen_params& aParams){
|
||||||
// TODO: prettier print
|
// TODO: prettier print
|
||||||
// TODO: Add call to print in log
|
// TODO: Add call to print in log
|
||||||
std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl;
|
std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl;
|
||||||
@ -76,7 +76,7 @@ void print_netgen_params(netgen_params& aParams){
|
|||||||
* @param param_file Name of the file
|
* @param param_file Name of the file
|
||||||
* @param aParams Structure to fill
|
* @param aParams Structure to fill
|
||||||
*/
|
*/
|
||||||
void import_netgen_params(const std::string param_file, netgen_params& aParams){
|
void importNetgenParams(const std::string param_file, netgen_params& aParams){
|
||||||
std::ifstream myfile(param_file);
|
std::ifstream myfile(param_file);
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ void import_netgen_params(const std::string param_file, netgen_params& aParams){
|
|||||||
* @param param_file the file
|
* @param param_file the file
|
||||||
* @param aParams the object
|
* @param aParams the object
|
||||||
*/
|
*/
|
||||||
void export_netgen_params(const std::string param_file, netgen_params& aParams){
|
void exportNetgenParams(const std::string param_file, netgen_params& aParams){
|
||||||
std::ofstream myfile(param_file);
|
std::ofstream myfile(param_file);
|
||||||
myfile << aParams.has_netgen_param << std::endl;
|
myfile << aParams.has_netgen_param << std::endl;
|
||||||
myfile << aParams.maxh << std::endl;
|
myfile << aParams.maxh << std::endl;
|
||||||
@ -182,7 +182,7 @@ void export_netgen_params(const std::string param_file, netgen_params& aParams){
|
|||||||
|
|
||||||
* @return true if the two object are identical
|
* @return true if the two object are identical
|
||||||
*/
|
*/
|
||||||
bool diff_netgen_params(netgen_params params1, netgen_params params2){
|
bool diffNetgenParams(netgen_params params1, netgen_params params2){
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
ret &= params1.maxh == params2.maxh;
|
ret &= params1.maxh == params2.maxh;
|
||||||
ret &= params1.minh == params2.minh;
|
ret &= params1.minh == params2.minh;
|
@ -20,13 +20,13 @@
|
|||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
|
||||||
// File : netgen_param.hxx
|
// File : NETGENPlugin_DriverParam.hxx
|
||||||
// Author : Yoann AUDOUIN, EDF
|
// Author : Yoann AUDOUIN, EDF
|
||||||
// Module : SMESH
|
// Module : NETGEN
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _NETGEN_PARAM_HXX_
|
#ifndef _NETGENPLUGIN_DRIVERPARAM_HXX_
|
||||||
#define _NETGEN_PARAM_HXX_
|
#define _NETGENPLUGIN_DRIVERPARAM_HXX_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@ -86,11 +86,11 @@ struct netgen_params{
|
|||||||
int nbThreads;
|
int nbThreads;
|
||||||
};
|
};
|
||||||
|
|
||||||
void print_netgen_params(netgen_params& aParams);
|
void printNetgenParams(netgen_params& aParams);
|
||||||
|
|
||||||
void import_netgen_params(const std::string param_file, netgen_params& aParams);
|
void importNetgenParams(const std::string param_file, netgen_params& aParams);
|
||||||
void export_netgen_params(const std::string param_file, netgen_params& aParams);
|
void exportNetgenParams(const std::string param_file, netgen_params& aParams);
|
||||||
|
|
||||||
bool diff_netgen_params(netgen_params params1, netgen_params params2);
|
bool diffNetgenParams(netgen_params params1, netgen_params params2);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
#include "NETGENPlugin_Mesher.hxx"
|
#include "NETGENPlugin_Mesher.hxx"
|
||||||
#include "NETGENPlugin_Hypothesis_2D.hxx"
|
#include "NETGENPlugin_Hypothesis_2D.hxx"
|
||||||
#include "NETGENPlugin_Provider.hxx"
|
#include "NETGENPlugin_DriverParam.hxx"
|
||||||
#include "netgen_param.hxx"
|
|
||||||
|
|
||||||
#include <SMDS_MeshElement.hxx>
|
#include <SMDS_MeshElement.hxx>
|
||||||
#include <SMDS_MeshNode.hxx>
|
#include <SMDS_MeshNode.hxx>
|
||||||
@ -41,8 +40,8 @@
|
|||||||
#include <StdMeshers_MaxElementArea.hxx>
|
#include <StdMeshers_MaxElementArea.hxx>
|
||||||
#include <StdMeshers_QuadranglePreference.hxx>
|
#include <StdMeshers_QuadranglePreference.hxx>
|
||||||
#include <StdMeshers_ViscousLayers2D.hxx>
|
#include <StdMeshers_ViscousLayers2D.hxx>
|
||||||
#include "DriverStep.hxx"
|
#include "SMESH_DriverStep.hxx"
|
||||||
#include "DriverMesh.hxx"
|
#include "SMESH_DriverMesh.hxx"
|
||||||
|
|
||||||
|
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
@ -324,17 +323,17 @@ bool NETGENPlugin_NETGEN_2D_ONLY::RemoteCompute(SMESH_Mesh& aMesh,
|
|||||||
fs::path output_mesh_file=tmp_folder / fs::path("output_mesh.med");
|
fs::path output_mesh_file=tmp_folder / fs::path("output_mesh.med");
|
||||||
fs::path shape_file=tmp_folder / fs::path("shape.step");
|
fs::path shape_file=tmp_folder / fs::path("shape.step");
|
||||||
fs::path param_file=tmp_folder / fs::path("netgen2d_param.txt");
|
fs::path param_file=tmp_folder / fs::path("netgen2d_param.txt");
|
||||||
fs::path log_file=tmp_folder / fs::path("run_mesher.log");
|
fs::path log_file=tmp_folder / fs::path("run.log");
|
||||||
//TODO: Handle variable mesh_name
|
//TODO: Handle variable mesh_name
|
||||||
std::string mesh_name = "Maillage_1";
|
std::string mesh_name = "Maillage_1";
|
||||||
|
|
||||||
//Writing Shape
|
//Writing Shape
|
||||||
export_shape(shape_file.string(), aShape);
|
exportShape(shape_file.string(), aShape);
|
||||||
//Writing hypo
|
//Writing hypo
|
||||||
netgen_params aParams;
|
netgen_params aParams;
|
||||||
FillParameters(_hypParameters, aParams);
|
FillParameters(_hypParameters, aParams);
|
||||||
|
|
||||||
export_netgen_params(param_file.string(), aParams);
|
exportNetgenParams(param_file.string(), aParams);
|
||||||
|
|
||||||
// Exporting element orientation
|
// Exporting element orientation
|
||||||
exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
|
exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
|
||||||
@ -347,7 +346,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::RemoteCompute(SMESH_Mesh& aMesh,
|
|||||||
fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
|
fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
|
||||||
fs::path("bin")/
|
fs::path("bin")/
|
||||||
fs::path("salome")/
|
fs::path("salome")/
|
||||||
fs::path("run_mesher");
|
fs::path("NETGENPlugin_Runner");
|
||||||
cmd = run_mesher_exe.string() +
|
cmd = run_mesher_exe.string() +
|
||||||
" NETGEN2D " + mesh_file.string() + " "
|
" NETGEN2D " + mesh_file.string() + " "
|
||||||
+ shape_file.string() + " "
|
+ shape_file.string() + " "
|
||||||
|
@ -32,9 +32,7 @@
|
|||||||
|
|
||||||
#include "NETGENPlugin_Hypothesis.hxx"
|
#include "NETGENPlugin_Hypothesis.hxx"
|
||||||
|
|
||||||
#include "DriverStep.hxx"
|
#include "NETGENPlugin_DriverParam.hxx"
|
||||||
#include "DriverMesh.hxx"
|
|
||||||
#include "netgen_param.hxx"
|
|
||||||
|
|
||||||
#include <SMDS_MeshElement.hxx>
|
#include <SMDS_MeshElement.hxx>
|
||||||
#include <SMDS_MeshNode.hxx>
|
#include <SMDS_MeshNode.hxx>
|
||||||
@ -50,6 +48,9 @@
|
|||||||
#include <StdMeshers_QuadToTriaAdaptor.hxx>
|
#include <StdMeshers_QuadToTriaAdaptor.hxx>
|
||||||
#include <StdMeshers_ViscousLayers.hxx>
|
#include <StdMeshers_ViscousLayers.hxx>
|
||||||
#include <SMESH_subMesh.hxx>
|
#include <SMESH_subMesh.hxx>
|
||||||
|
#include <SMESH_DriverStep.hxx>
|
||||||
|
#include <SMESH_DriverMesh.hxx>
|
||||||
|
|
||||||
|
|
||||||
#include <BRepGProp.hxx>
|
#include <BRepGProp.hxx>
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
@ -196,7 +197,7 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh& aMesh,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NETGENPlugin_NETGEN_3D::FillParameters(const NETGENPlugin_Hypothesis* hyp, netgen_params &aParams)
|
void NETGENPlugin_NETGEN_3D::fillParameters(const NETGENPlugin_Hypothesis* hyp, netgen_params &aParams)
|
||||||
{
|
{
|
||||||
aParams.maxh = hyp->GetMaxSize();
|
aParams.maxh = hyp->GetMaxSize();
|
||||||
aParams.minh = hyp->GetMinSize();
|
aParams.minh = hyp->GetMinSize();
|
||||||
@ -315,21 +316,21 @@ int NETGENPlugin_NETGEN_3D::RemoteCompute(SMESH_Mesh& aMesh,
|
|||||||
fs::path output_mesh_file=tmp_folder / fs::path("output_mesh.med");
|
fs::path output_mesh_file=tmp_folder / fs::path("output_mesh.med");
|
||||||
fs::path shape_file=tmp_folder / fs::path("shape.step");
|
fs::path shape_file=tmp_folder / fs::path("shape.step");
|
||||||
fs::path param_file=tmp_folder / fs::path("netgen3d_param.txt");
|
fs::path param_file=tmp_folder / fs::path("netgen3d_param.txt");
|
||||||
fs::path log_file=tmp_folder / fs::path("run_mesher.log");
|
fs::path log_file=tmp_folder / fs::path("run.log");
|
||||||
//TODO: Handle variable mesh_name
|
//TODO: Handle variable mesh_name
|
||||||
std::string mesh_name = "Maillage_1";
|
std::string mesh_name = "Maillage_1";
|
||||||
|
|
||||||
//Writing Shape
|
//Writing Shape
|
||||||
export_shape(shape_file.string(), aShape);
|
exportShape(shape_file.string(), aShape);
|
||||||
auto time2 = std::chrono::high_resolution_clock::now();
|
auto time2 = std::chrono::high_resolution_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time2-time1);
|
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time2-time1);
|
||||||
std::cout << "Time for export_shape: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for exportShape: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
|
|
||||||
//Writing hypo
|
//Writing hypo
|
||||||
netgen_params aParams;
|
netgen_params aParams;
|
||||||
FillParameters(_hypParameters, aParams);
|
fillParameters(_hypParameters, aParams);
|
||||||
|
|
||||||
export_netgen_params(param_file.string(), aParams);
|
exportNetgenParams(param_file.string(), aParams);
|
||||||
auto time3 = std::chrono::high_resolution_clock::now();
|
auto time3 = std::chrono::high_resolution_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time3-time2);
|
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time3-time2);
|
||||||
std::cout << "Time for fill+export param: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for fill+export param: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
@ -338,7 +339,7 @@ int NETGENPlugin_NETGEN_3D::RemoteCompute(SMESH_Mesh& aMesh,
|
|||||||
exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
|
exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
|
||||||
auto time4 = std::chrono::high_resolution_clock::now();
|
auto time4 = std::chrono::high_resolution_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time4-time3);
|
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time4-time3);
|
||||||
std::cout << "Time for exportElemnOrient: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for exportElemOrient: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
|
|
||||||
aMesh.Unlock();
|
aMesh.Unlock();
|
||||||
// Calling run_mesher
|
// Calling run_mesher
|
||||||
@ -348,7 +349,7 @@ int NETGENPlugin_NETGEN_3D::RemoteCompute(SMESH_Mesh& aMesh,
|
|||||||
fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
|
fs::path(std::getenv("NETGENPLUGIN_ROOT_DIR"))/
|
||||||
fs::path("bin")/
|
fs::path("bin")/
|
||||||
fs::path("salome")/
|
fs::path("salome")/
|
||||||
fs::path("run_mesher");
|
fs::path("NETGENPlugin_Runner");
|
||||||
cmd = run_mesher_exe.string() +
|
cmd = run_mesher_exe.string() +
|
||||||
" NETGEN3D " + mesh_file.string() + " "
|
" NETGEN3D " + mesh_file.string() + " "
|
||||||
+ shape_file.string() + " "
|
+ shape_file.string() + " "
|
||||||
@ -356,8 +357,7 @@ int NETGENPlugin_NETGEN_3D::RemoteCompute(SMESH_Mesh& aMesh,
|
|||||||
+ element_orientation_file.string() + " "
|
+ element_orientation_file.string() + " "
|
||||||
+ std::to_string(aMesh.GetMesherNbThreads()) + " "
|
+ std::to_string(aMesh.GetMesherNbThreads()) + " "
|
||||||
+ new_element_file.string() + " "
|
+ new_element_file.string() + " "
|
||||||
+ std::to_string(0) + " "
|
+ "NONE" +
|
||||||
+ output_mesh_file.string() +
|
|
||||||
" >> " + log_file.string();
|
" >> " + log_file.string();
|
||||||
|
|
||||||
//std::cout << "Running command: " << std::endl;
|
//std::cout << "Running command: " << std::endl;
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#ifndef _NETGENPlugin_NETGEN_3D_HXX_
|
#ifndef _NETGENPlugin_NETGEN_3D_HXX_
|
||||||
#define _NETGENPlugin_NETGEN_3D_HXX_
|
#define _NETGENPlugin_NETGEN_3D_HXX_
|
||||||
|
|
||||||
#include "NETGENPlugin_Provider.hxx"
|
|
||||||
#include "NETGENPlugin_Defs.hxx"
|
#include "NETGENPlugin_Defs.hxx"
|
||||||
#include "NETGENPlugin_Mesher.hxx"
|
#include "NETGENPlugin_Mesher.hxx"
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo
|
|||||||
netgen_params& aParams,
|
netgen_params& aParams,
|
||||||
const std::string output_file);
|
const std::string output_file);
|
||||||
|
|
||||||
void FillParameters(const NETGENPlugin_Hypothesis* hyp,
|
void fillParameters(const NETGENPlugin_Hypothesis* hyp,
|
||||||
netgen_params &aParams);
|
netgen_params &aParams);
|
||||||
|
|
||||||
int RemoteCompute(SMESH_Mesh& aMesh,
|
int RemoteCompute(SMESH_Mesh& aMesh,
|
||||||
|
@ -1,152 +0,0 @@
|
|||||||
// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
//
|
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
||||||
//
|
|
||||||
|
|
||||||
// File : NETGENPlugin_Provider.hxx
|
|
||||||
// Author : Yoann AUDOUIN (EDF)
|
|
||||||
// Project : SALOME
|
|
||||||
//
|
|
||||||
#ifndef _NETGENPlugin_Provider_HXX_
|
|
||||||
#define _NETGENPlugin_Provider_HXX_
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <thread>
|
|
||||||
#include <array>
|
|
||||||
#include <vector>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
namespace nglib {
|
|
||||||
#include <nglib.h>
|
|
||||||
}
|
|
||||||
#ifndef OCCGEOMETRY
|
|
||||||
#define OCCGEOMETRY
|
|
||||||
#endif
|
|
||||||
#include <occgeom.hpp>
|
|
||||||
#include <meshing.hpp>
|
|
||||||
|
|
||||||
template<class T, int NDATA>
|
|
||||||
class ProviderPtr{
|
|
||||||
public:
|
|
||||||
|
|
||||||
ProviderPtr(){
|
|
||||||
for(int i=0;i<NDATA;i++){
|
|
||||||
this->_mydata[i] = nullptr;
|
|
||||||
this->_useddata[i] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int take(T** data){
|
|
||||||
|
|
||||||
this->_mymutex.lock();
|
|
||||||
*data = nullptr;
|
|
||||||
for(int i=0;i<NDATA;i++){
|
|
||||||
if(!this->_useddata[i]){
|
|
||||||
if (this->_mydata[i] == nullptr)
|
|
||||||
this->_mydata[i] = new T();
|
|
||||||
this->_useddata[i] = true;
|
|
||||||
*data = this->_mydata[i];
|
|
||||||
this->_mymutex.unlock();
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->_mymutex.unlock();
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
bool release(int i, bool clean){
|
|
||||||
|
|
||||||
this->_mymutex.lock();
|
|
||||||
|
|
||||||
if(clean){
|
|
||||||
delete this->_mydata[i];
|
|
||||||
this->_mydata[i] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->_useddata[i] = false;
|
|
||||||
|
|
||||||
this->_mymutex.unlock();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
void dump(){
|
|
||||||
std::cout << "Dumping provider:" << std::endl;
|
|
||||||
for(int i=0;i<NDATA;i++){
|
|
||||||
std::cout << " - " << i << " used: " << this->_useddata[i] << std::endl;
|
|
||||||
std::cout << " - adress: " << this->_mydata[i] << std::endl;
|
|
||||||
if (this->_mydata[i] != nullptr)
|
|
||||||
std::cout << " - i: " << this->_mydata[i]->i << " d: " << this->_mydata[i]->d << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::array<T*, NDATA> _mydata;
|
|
||||||
std::array<bool, NDATA> _useddata;
|
|
||||||
std::mutex _mymutex;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, int NDATA>
|
|
||||||
class Provider{
|
|
||||||
public:
|
|
||||||
|
|
||||||
Provider() = default;
|
|
||||||
|
|
||||||
int take(T& data){
|
|
||||||
|
|
||||||
this->_mymutex.lock();
|
|
||||||
for(int i=0;i<NDATA;i++){
|
|
||||||
if(!this->_useddata[i]){
|
|
||||||
this->_useddata[i] = true;
|
|
||||||
data = this->_mydata[i];
|
|
||||||
this->_mymutex.unlock();
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->_mymutex.unlock();
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
bool release(int i){
|
|
||||||
|
|
||||||
this->_mymutex.lock();
|
|
||||||
this->_useddata[i] = false;
|
|
||||||
this->_mymutex.unlock();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
void dump(){
|
|
||||||
std::cout << "Dumping provider:" << std::endl;
|
|
||||||
for(int i=0;i<NDATA;i++){
|
|
||||||
std::cout << " - " << i << " used: " << this->_useddata[i] << std::endl;
|
|
||||||
std::cout << " - i: " << this->_mydata[i].i << " d: " << this->_mydata[i].d << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::array<T, NDATA> _mydata;
|
|
||||||
std::array<bool, NDATA> _useddata;
|
|
||||||
std::mutex _mymutex;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -20,21 +20,20 @@
|
|||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
|
||||||
// File : netgen_mesher.cxx
|
// File : NETGENPlugin_Runner.cxx
|
||||||
// Author : Yoann AUDOUIN, EDF
|
// Author : Yoann AUDOUIN, EDF
|
||||||
// Module : SMESH
|
// Module : SMESH
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "netgen_mesher.hxx"
|
#include "NETGENPlugin_Runner.hxx"
|
||||||
|
|
||||||
#include "DriverStep.hxx"
|
|
||||||
#include "DriverMesh.hxx"
|
#include "NETGENPlugin_DriverParam.hxx"
|
||||||
#include "netgen_param.hxx"
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <filesystem>
|
#include <boost/filesystem.hpp>
|
||||||
namespace fs = std::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
// SMESH include
|
// SMESH include
|
||||||
@ -51,6 +50,8 @@ namespace fs = std::filesystem;
|
|||||||
#include <StdMeshers_QuadToTriaAdaptor.hxx>
|
#include <StdMeshers_QuadToTriaAdaptor.hxx>
|
||||||
#include <StdMeshers_ViscousLayers.hxx>
|
#include <StdMeshers_ViscousLayers.hxx>
|
||||||
#include <StdMeshers_ViscousLayers2D.hxx>
|
#include <StdMeshers_ViscousLayers2D.hxx>
|
||||||
|
#include <SMESH_DriverStep.hxx>
|
||||||
|
#include <SMESH_DriverMesh.hxx>
|
||||||
|
|
||||||
|
|
||||||
// NETGENPlugin
|
// NETGENPlugin
|
||||||
@ -186,7 +187,6 @@ int netgen3d(const std::string input_mesh_file,
|
|||||||
const std::string hypo_file,
|
const std::string hypo_file,
|
||||||
const std::string element_orientation_file,
|
const std::string element_orientation_file,
|
||||||
const std::string new_element_file,
|
const std::string new_element_file,
|
||||||
bool output_mesh,
|
|
||||||
const std::string output_mesh_file,
|
const std::string output_mesh_file,
|
||||||
int nbThreads)
|
int nbThreads)
|
||||||
{
|
{
|
||||||
@ -198,22 +198,22 @@ int netgen3d(const std::string input_mesh_file,
|
|||||||
//TODO: To define
|
//TODO: To define
|
||||||
std::string mesh_name = "Maillage_1";
|
std::string mesh_name = "Maillage_1";
|
||||||
|
|
||||||
import_mesh(input_mesh_file, *myMesh, mesh_name);
|
importMesh(input_mesh_file, *myMesh, mesh_name);
|
||||||
auto time1 = std::chrono::high_resolution_clock::now();
|
auto time1 = std::chrono::high_resolution_clock::now();
|
||||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time1-time0);
|
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time1-time0);
|
||||||
std::cout << "Time for import_mesh: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for importMesh: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
|
|
||||||
// Importing shape
|
// Importing shape
|
||||||
TopoDS_Shape myShape;
|
TopoDS_Shape myShape;
|
||||||
import_shape(shape_file, myShape);
|
importShape(shape_file, myShape);
|
||||||
auto time2 = std::chrono::high_resolution_clock::now();
|
auto time2 = std::chrono::high_resolution_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time2-time1);
|
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time2-time1);
|
||||||
std::cout << "Time for import_shape: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for importShape: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
|
|
||||||
// Importing hypothesis
|
// Importing hypothesis
|
||||||
netgen_params myParams;
|
netgen_params myParams;
|
||||||
|
|
||||||
import_netgen_params(hypo_file, myParams);
|
importNetgenParams(hypo_file, myParams);
|
||||||
auto time3 = std::chrono::high_resolution_clock::now();
|
auto time3 = std::chrono::high_resolution_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time3-time2);
|
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time3-time2);
|
||||||
std::cout << "Time for import_netgen_param: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for import_netgen_param: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
@ -221,9 +221,9 @@ int netgen3d(const std::string input_mesh_file,
|
|||||||
myParams.nbThreads = nbThreads;
|
myParams.nbThreads = nbThreads;
|
||||||
|
|
||||||
std::cout << "Meshing with netgen3d" << std::endl;
|
std::cout << "Meshing with netgen3d" << std::endl;
|
||||||
int ret = netgen3d_internal(myShape, *myMesh, myParams,
|
int ret = netgen3dInternal(myShape, *myMesh, myParams,
|
||||||
new_element_file, element_orientation_file,
|
new_element_file, element_orientation_file,
|
||||||
output_mesh);
|
!output_mesh_file.empty());
|
||||||
|
|
||||||
|
|
||||||
if(!ret){
|
if(!ret){
|
||||||
@ -231,12 +231,12 @@ int netgen3d(const std::string input_mesh_file,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(output_mesh){
|
if(!output_mesh_file.empty()){
|
||||||
auto time4 = std::chrono::high_resolution_clock::now();
|
auto time4 = std::chrono::high_resolution_clock::now();
|
||||||
export_mesh(output_mesh_file, *myMesh, mesh_name);
|
exportMesh(output_mesh_file, *myMesh, mesh_name);
|
||||||
auto time5 = std::chrono::high_resolution_clock::now();
|
auto time5 = std::chrono::high_resolution_clock::now();
|
||||||
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time5-time4);
|
elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(time5-time4);
|
||||||
std::cout << "Time for export_mesh: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for exportMesh: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -249,10 +249,12 @@ int netgen3d(const std::string input_mesh_file,
|
|||||||
* @param aMesh the mesh
|
* @param aMesh the mesh
|
||||||
* @param aParams the netgen parameters
|
* @param aParams the netgen parameters
|
||||||
* @param new_element_file file containing data on the new point/tetra added by netgen
|
* @param new_element_file file containing data on the new point/tetra added by netgen
|
||||||
|
* @param element_orientation_file file containing data on the orientation of each element to add to netgen
|
||||||
|
* @param output_mesh if true add element created by netgen into aMesh
|
||||||
*
|
*
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int netgen3d_internal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
int netgen3dInternal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
||||||
std::string new_element_file, std::string element_orientation_file,
|
std::string new_element_file, std::string element_orientation_file,
|
||||||
bool output_mesh)
|
bool output_mesh)
|
||||||
{
|
{
|
||||||
@ -317,20 +319,31 @@ int netgen3d_internal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aP
|
|||||||
// Get list of elements + their orientation from element_orientation file
|
// Get list of elements + their orientation from element_orientation file
|
||||||
std::map<vtkIdType, bool> elemOrientation;
|
std::map<vtkIdType, bool> elemOrientation;
|
||||||
{
|
{
|
||||||
std::ifstream df(element_orientation_file, ios::binary|ios::in);
|
// Setting all element orientation to false if there no element orientation file
|
||||||
int nbElement;
|
if(element_orientation_file.empty()){
|
||||||
bool orient;
|
SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face);
|
||||||
|
while ( iteratorElem->more() ) // loop on elements on a geom face
|
||||||
|
{
|
||||||
|
// check mesh face
|
||||||
|
const SMDS_MeshElement* elem = iteratorElem->next();
|
||||||
|
elemOrientation[elem->GetID()] = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::ifstream df(element_orientation_file, ios::binary|ios::in);
|
||||||
|
int nbElement;
|
||||||
|
bool orient;
|
||||||
|
|
||||||
// Warning of the use of vtkIdType (I had issue when run_mesher was compiled with internal vtk) and salome not
|
// Warning of the use of vtkIdType (I had issue when run_mesher was compiled with internal vtk) and salome not
|
||||||
// Sizeof was the same but how he othered the type was different
|
// Sizeof was the same but how he othered the type was different
|
||||||
// Maybe using another type (uint64_t) instead would be better
|
// Maybe using another type (uint64_t) instead would be better
|
||||||
vtkIdType id;
|
vtkIdType id;
|
||||||
df.read((char*)&nbElement, sizeof(int));
|
df.read((char*)&nbElement, sizeof(int));
|
||||||
|
|
||||||
for(int ielem=0;ielem<nbElement;++ielem){
|
for(int ielem=0;ielem<nbElement;++ielem){
|
||||||
df.read((char*) &id, sizeof(vtkIdType));
|
df.read((char*) &id, sizeof(vtkIdType));
|
||||||
df.read((char*) &orient, sizeof(bool));
|
df.read((char*) &orient, sizeof(bool));
|
||||||
elemOrientation[id] = orient;
|
elemOrientation[id] = orient;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +369,6 @@ int netgen3d_internal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aP
|
|||||||
if(!isIn)
|
if(!isIn)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
// Get orientation
|
// Get orientation
|
||||||
// Netgen requires that all the triangle point outside
|
// Netgen requires that all the triangle point outside
|
||||||
isRev = elemOrientation[elem->GetID()];
|
isRev = elemOrientation[elem->GetID()];
|
||||||
@ -542,7 +554,7 @@ int netgen3d_internal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aP
|
|||||||
std::cout << "Time for netgen_compute: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for netgen_compute: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
|
|
||||||
bool isOK = ( /*status == NG_OK &&*/ Netgen_NbOfTetra > 0 );// get whatever built
|
bool isOK = ( /*status == NG_OK &&*/ Netgen_NbOfTetra > 0 );// get whatever built
|
||||||
if ( isOK )
|
if ( isOK && !new_element_file.empty() )
|
||||||
{
|
{
|
||||||
std::ofstream df(new_element_file, ios::out|ios::binary);
|
std::ofstream df(new_element_file, ios::out|ios::binary);
|
||||||
|
|
||||||
@ -581,7 +593,7 @@ int netgen3d_internal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aP
|
|||||||
std::cout << "Time for write_new_elem: " << elapsed.count() * 1e-9 << std::endl;
|
std::cout << "Time for write_new_elem: " << elapsed.count() * 1e-9 << std::endl;
|
||||||
|
|
||||||
|
|
||||||
// Adding new files in aMesh as well
|
// Adding new elements in aMesh as well
|
||||||
if ( output_mesh )
|
if ( output_mesh )
|
||||||
{
|
{
|
||||||
double Netgen_point[3];
|
double Netgen_point[3];
|
||||||
@ -639,7 +651,6 @@ int netgen2d(const std::string input_mesh_file,
|
|||||||
const std::string hypo_file,
|
const std::string hypo_file,
|
||||||
const std::string element_orientation_file,
|
const std::string element_orientation_file,
|
||||||
const std::string new_element_file,
|
const std::string new_element_file,
|
||||||
bool output_mesh,
|
|
||||||
const std::string output_mesh_file)
|
const std::string output_mesh_file)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -650,29 +661,29 @@ int netgen2d(const std::string input_mesh_file,
|
|||||||
//TODO: To define
|
//TODO: To define
|
||||||
std::string mesh_name = "Maillage_1";
|
std::string mesh_name = "Maillage_1";
|
||||||
|
|
||||||
import_mesh(input_mesh_file, *myMesh, mesh_name);
|
importMesh(input_mesh_file, *myMesh, mesh_name);
|
||||||
|
|
||||||
// Importing shape
|
// Importing shape
|
||||||
TopoDS_Shape myShape;
|
TopoDS_Shape myShape;
|
||||||
import_shape(shape_file, myShape);
|
importShape(shape_file, myShape);
|
||||||
|
|
||||||
// Importing hypothesis
|
// Importing hypothesis
|
||||||
netgen_params myParams;
|
netgen_params myParams;
|
||||||
|
|
||||||
import_netgen_params(hypo_file, myParams);
|
importNetgenParams(hypo_file, myParams);
|
||||||
|
|
||||||
std::cout << "Meshing with netgen3d" << std::endl;
|
std::cout << "Meshing with netgen3d" << std::endl;
|
||||||
int ret = netgen2d_internal(myShape, *myMesh, myParams,
|
int ret = netgen2dInternal(myShape, *myMesh, myParams,
|
||||||
new_element_file, element_orientation_file,
|
new_element_file, element_orientation_file,
|
||||||
output_mesh);
|
!output_mesh_file.empty());
|
||||||
|
|
||||||
if(!ret){
|
if(!ret){
|
||||||
std::cout << "Meshing failed" << std::endl;
|
std::cout << "Meshing failed" << std::endl;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(output_mesh)
|
if(!output_mesh_file.empty())
|
||||||
export_mesh(output_mesh_file, *myMesh, mesh_name);
|
exportMesh(output_mesh_file, *myMesh, mesh_name);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -689,7 +700,7 @@ int netgen2d(const std::string input_mesh_file,
|
|||||||
*
|
*
|
||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int netgen2d_internal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
int netgen2dInternal(TopoDS_Shape &aShape, SMESH_Mesh& aMesh, netgen_params& aParams,
|
||||||
std::string new_element_file, std::string element_orientation_file,
|
std::string new_element_file, std::string element_orientation_file,
|
||||||
bool output_mesh)
|
bool output_mesh)
|
||||||
{
|
{
|
@ -20,13 +20,13 @@
|
|||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
//
|
//
|
||||||
|
|
||||||
// File : netgen_mesher.hxx
|
// File : NETGENPlugin_Runner.hxx
|
||||||
// Author : Yoann AUDOUIN, EDF
|
// Author : Yoann AUDOUIN, EDF
|
||||||
// Module : SMESH
|
// Module : NETGEN
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef _NETGEN_MESHER_HXX_
|
#ifndef _NETGENPLUGIN_RUNNER_HXX_
|
||||||
#define _NETGEN_MESHER_HXX_
|
#define _NETGENPLUGIN_RUNNER_HXX_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -36,7 +36,7 @@ class SMESH_Mesh;
|
|||||||
class SMESH_Comment;
|
class SMESH_Comment;
|
||||||
class netgen_params;
|
class netgen_params;
|
||||||
|
|
||||||
int netgen2d_internal(TopoDS_Shape &aShape,
|
int netgen2dInternal(TopoDS_Shape &aShape,
|
||||||
SMESH_Mesh& aMesh,
|
SMESH_Mesh& aMesh,
|
||||||
netgen_params& aParams,
|
netgen_params& aParams,
|
||||||
std::string new_element_file,
|
std::string new_element_file,
|
||||||
@ -45,12 +45,11 @@ int netgen2d_internal(TopoDS_Shape &aShape,
|
|||||||
int netgen2d(const std::string input_mesh_file,
|
int netgen2d(const std::string input_mesh_file,
|
||||||
const std::string shape_file,
|
const std::string shape_file,
|
||||||
const std::string hypo_file,
|
const std::string hypo_file,
|
||||||
const std::string element_orienation_file,
|
const std::string element_orientation_file,
|
||||||
const std::string new_element_file,
|
const std::string new_element_file,
|
||||||
bool output_mesh,
|
|
||||||
const std::string output_mesh_file);
|
const std::string output_mesh_file);
|
||||||
|
|
||||||
int netgen3d_internal(TopoDS_Shape &aShape,
|
int netgen3dInternal(TopoDS_Shape &aShape,
|
||||||
SMESH_Mesh& aMesh,
|
SMESH_Mesh& aMesh,
|
||||||
netgen_params& aParams,
|
netgen_params& aParams,
|
||||||
std::string new_element_file,
|
std::string new_element_file,
|
||||||
@ -59,9 +58,8 @@ int netgen3d_internal(TopoDS_Shape &aShape,
|
|||||||
int netgen3d(const std::string input_mesh_file,
|
int netgen3d(const std::string input_mesh_file,
|
||||||
const std::string shape_file,
|
const std::string shape_file,
|
||||||
const std::string hypo_file,
|
const std::string hypo_file,
|
||||||
const std::string element_orienation_file,
|
const std::string element_orientation_file,
|
||||||
const std::string new_element_file,
|
const std::string new_element_file,
|
||||||
bool output_mesh,
|
|
||||||
const std::string output_mesh_file,
|
const std::string output_mesh_file,
|
||||||
int nbThreads);
|
int nbThreads);
|
||||||
|
|
105
src/NETGENPlugin/NETGENPlugin_Runner_main.cxx
Normal file
105
src/NETGENPlugin/NETGENPlugin_Runner_main.cxx
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||||
|
//
|
||||||
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||||
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public
|
||||||
|
// License as published by the Free Software Foundation; either
|
||||||
|
// version 2.1 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
//
|
||||||
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||||
|
//
|
||||||
|
|
||||||
|
// File : NETGENplugin_Runnner_main.cxx
|
||||||
|
// Author : Yoann AUDOUIN, EDF
|
||||||
|
// Module : NETGEN
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "NETGENPlugin_Runner.hxx"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main function
|
||||||
|
*
|
||||||
|
* @param argc Number of arguments
|
||||||
|
* @param argv Arguments
|
||||||
|
*
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
int main(int argc, char *argv[]){
|
||||||
|
|
||||||
|
if(argc!=9||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
|
||||||
|
std::cout << "Error in number of arguments "<< argc<<" given expected 8" <<std::endl;
|
||||||
|
std::cout << "Syntax:"<<std::endl;
|
||||||
|
std::cout << "run_mesher MESHER INPUT_MESH_FILE SHAPE_FILE HYPO_FILE" << std::endl;
|
||||||
|
std::cout << " ELEM_ORIENT_FILE NB_THREADS" << std::endl;
|
||||||
|
std::cout << " NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << " Set argument to NONE to ignore them " << std::endl;
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "Args:" << std::endl;
|
||||||
|
std::cout << " MESHER: mesher to use from (NETGEN3D, NETGEN2D)" << std::endl;
|
||||||
|
std::cout << " INPUT_MESH_FILE: MED File containing lower-dimension-elements already meshed" << std::endl;
|
||||||
|
std::cout << " SHAPE_FILE: STEP file containing the shape to mesh" << std::endl;
|
||||||
|
std::cout << " HYPO_FILE: Ascii file containint the list of parameters" << std::endl;
|
||||||
|
std::cout << " (optional) ELEM_ORIENT_FILE: binary file containing the list of element from INPUT_MESH_FILE associated to the shape and their orientation" << std::endl;
|
||||||
|
std::cout << " NB_THREADS: Number of thread to use for the mesher" << std::endl;
|
||||||
|
std::cout << " (optional) NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << std::endl;
|
||||||
|
std::cout << " (optional) OUTPUT_MESH_FILE: (out) MED File containing the mesh after the run of the mesher" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
std::string mesher=argv[1];
|
||||||
|
std::string input_mesh_file=argv[2];
|
||||||
|
std::string shape_file=argv[3];
|
||||||
|
std::string hypo_file=argv[4];
|
||||||
|
std::string element_orientation_file=argv[5];
|
||||||
|
int nbThreads=std::stoi(argv[6]);
|
||||||
|
std::string new_element_file=argv[7];
|
||||||
|
std::string output_mesh_file=argv[8];
|
||||||
|
|
||||||
|
if (output_mesh_file == "NONE")
|
||||||
|
output_mesh_file = "";
|
||||||
|
if (element_orientation_file == "NONE")
|
||||||
|
element_orientation_file = "";
|
||||||
|
if (new_element_file == "NONE")
|
||||||
|
new_element_file = "";
|
||||||
|
|
||||||
|
if (mesher=="NETGEN3D"){
|
||||||
|
auto begin = std::chrono::high_resolution_clock::now();
|
||||||
|
netgen3d(input_mesh_file,
|
||||||
|
shape_file,
|
||||||
|
hypo_file,
|
||||||
|
element_orientation_file,
|
||||||
|
new_element_file,
|
||||||
|
output_mesh_file,
|
||||||
|
nbThreads);
|
||||||
|
auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
|
||||||
|
std::cout << "Time elapsed: " << elapsed.count()*1e-9 << std::endl;
|
||||||
|
} else if (mesher=="NETGEN2D"){
|
||||||
|
netgen2d(input_mesh_file,
|
||||||
|
shape_file,
|
||||||
|
hypo_file,
|
||||||
|
element_orientation_file,
|
||||||
|
new_element_file,
|
||||||
|
output_mesh_file);
|
||||||
|
} else {
|
||||||
|
std::cerr << "Unknown mesher:" << mesher << std::endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
@ -1,242 +0,0 @@
|
|||||||
// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
|
|
||||||
//
|
|
||||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
||||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
||||||
//
|
|
||||||
// This library is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU Lesser General Public
|
|
||||||
// License as published by the Free Software Foundation; either
|
|
||||||
// version 2.1 of the License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// Lesser General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU Lesser General Public
|
|
||||||
// License along with this library; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
//
|
|
||||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
||||||
//
|
|
||||||
|
|
||||||
// File : run_mesher.cxx
|
|
||||||
// Author : Yoann AUDOUIN, EDF
|
|
||||||
// Module : SMESH
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "DriverStep.hxx"
|
|
||||||
#include "DriverMesh.hxx"
|
|
||||||
#include "netgen_param.hxx"
|
|
||||||
#include "netgen_mesher.hxx"
|
|
||||||
|
|
||||||
#include <SMESH_Mesh.hxx>
|
|
||||||
#include <SMESH_Gen.hxx>
|
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Test of shape Import/Export
|
|
||||||
*
|
|
||||||
* @param shape_file
|
|
||||||
*/
|
|
||||||
void test_shape(){
|
|
||||||
|
|
||||||
std::cout << "Testing Shape Import/Export" << std::endl;
|
|
||||||
std::string shape_file = "box.step";
|
|
||||||
|
|
||||||
TopoDS_Shape myShape;
|
|
||||||
|
|
||||||
// Test 1 import -> export cmp files
|
|
||||||
std::string shape_file2 = "/tmp/shape.step";
|
|
||||||
|
|
||||||
import_shape(shape_file, myShape);
|
|
||||||
export_shape(shape_file2, myShape);
|
|
||||||
|
|
||||||
assert(diff_step_file(shape_file, shape_file2));
|
|
||||||
|
|
||||||
// Test 2 import->export->import cmp TopoDS_Shape
|
|
||||||
std::string shape_file3 = "/tmp/shape2.step";
|
|
||||||
TopoDS_Shape myShape1, myShape2;
|
|
||||||
|
|
||||||
import_shape(shape_file, myShape1);
|
|
||||||
|
|
||||||
export_shape(shape_file3, myShape1);
|
|
||||||
|
|
||||||
import_shape(shape_file3, myShape2);
|
|
||||||
|
|
||||||
// TODO: See why this does not work
|
|
||||||
// TShape seems to be different
|
|
||||||
//assert(myShape1.IsSame(myShape2));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief test of mesh import/export
|
|
||||||
*
|
|
||||||
* @param mesh_file
|
|
||||||
*/
|
|
||||||
void test_mesh(){
|
|
||||||
|
|
||||||
std::cout << "Testing Mesh Import/Export" << std::endl;
|
|
||||||
std::string mesh_file = "box.med";
|
|
||||||
SMESH_Gen gen;
|
|
||||||
|
|
||||||
SMESH_Mesh *myMesh = gen.CreateMesh(false);
|
|
||||||
std::string mesh_name = "Maillage_1";
|
|
||||||
|
|
||||||
// Test 1 import -> export cmp files
|
|
||||||
std::string mesh_file2 = "/tmp/mesh.med";
|
|
||||||
|
|
||||||
import_mesh(mesh_file, *myMesh, mesh_name);
|
|
||||||
export_mesh(mesh_file2, *myMesh, mesh_name);
|
|
||||||
|
|
||||||
assert(diff_med_file(mesh_file, mesh_file2, mesh_name));
|
|
||||||
|
|
||||||
// TODO: Compare the two med files via dump ?
|
|
||||||
|
|
||||||
// Test 2 import->export->import cmp TopoDS_Shape
|
|
||||||
std::string mesh_file3 = "/tmp/mesh2.med";
|
|
||||||
SMESH_Mesh *myMesh1 = gen.CreateMesh(false);
|
|
||||||
SMESH_Mesh *myMesh2 = gen.CreateMesh(false);
|
|
||||||
|
|
||||||
import_mesh(mesh_file, *myMesh1, mesh_name);
|
|
||||||
|
|
||||||
export_mesh(mesh_file3, *myMesh1, mesh_name);
|
|
||||||
|
|
||||||
import_mesh(mesh_file3, *myMesh2, mesh_name);
|
|
||||||
|
|
||||||
// TODO: Compare SMESH_Mesh
|
|
||||||
//assert(myMesh1==myMesh2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Test of import/export of netgen param
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
void test_netgen_params(){
|
|
||||||
|
|
||||||
std::string param_file = "/tmp/netgen_param.txt";
|
|
||||||
netgen_params myParams, myParams2;
|
|
||||||
myParams.has_netgen_param = true;
|
|
||||||
myParams.maxh = 34.64;
|
|
||||||
myParams.minh = 0.14;
|
|
||||||
myParams.segmentsperedge = 15;
|
|
||||||
myParams.grading = 0.2;
|
|
||||||
myParams.curvaturesafety = 1.5;
|
|
||||||
myParams.secondorder = false;
|
|
||||||
myParams.quad = false;
|
|
||||||
myParams.optimize = true;
|
|
||||||
myParams.fineness = 5;
|
|
||||||
myParams.uselocalh = true;
|
|
||||||
myParams.merge_solids = true;
|
|
||||||
myParams.chordalError = -1;
|
|
||||||
myParams.optsteps2d = 3;
|
|
||||||
myParams.optsteps3d = 3;
|
|
||||||
myParams.elsizeweight = 0.2;
|
|
||||||
myParams.opterrpow = 2;
|
|
||||||
myParams.delaunay = true;
|
|
||||||
myParams.checkoverlap = true;
|
|
||||||
myParams.checkchartboundary = false;
|
|
||||||
myParams.closeedgefac = 2;
|
|
||||||
myParams.has_local_size = false;
|
|
||||||
myParams.meshsizefilename = "";
|
|
||||||
myParams.has_maxelementvolume_hyp = false;
|
|
||||||
myParams.maxElementVolume = 0.0;
|
|
||||||
|
|
||||||
export_netgen_params(param_file, myParams);
|
|
||||||
import_netgen_params(param_file, myParams2);
|
|
||||||
|
|
||||||
assert(diff_netgen_params(myParams, myParams2));
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void test_netgen3d(){
|
|
||||||
|
|
||||||
std::cout << "Testing NETGEN 3D mesher" << std::endl;
|
|
||||||
netgen3d("box_partial2D1D-2.med",
|
|
||||||
"box-2.step",
|
|
||||||
"box_param.txt",
|
|
||||||
"element_orient.dat",
|
|
||||||
"new_element.dat",
|
|
||||||
true,
|
|
||||||
"box_with3D.med",
|
|
||||||
1);
|
|
||||||
|
|
||||||
// TODO: Check result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Main function
|
|
||||||
*
|
|
||||||
* @param argc Number of arguments
|
|
||||||
* @param argv Arguments
|
|
||||||
*
|
|
||||||
* @return error code
|
|
||||||
*/
|
|
||||||
int main(int argc, char *argv[]){
|
|
||||||
|
|
||||||
if(argc!=10||(argc==2 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help")==0))){
|
|
||||||
std::cout << "Error in number of argument"<<std::endl;
|
|
||||||
std::cout << "Syntax:"<<std::endl;
|
|
||||||
std::cout << "run_mesher MESHER INPUT_MESH_FILE SHAPE_FILE HYPO_FILE" << std::endl;
|
|
||||||
std::cout << " ELEM_ORIENT_FILE NB_THREADS" << std::endl;
|
|
||||||
std::cout << " NEW_ELEMENT_FILE OUTPUT_MESH_FILE" << std::endl;
|
|
||||||
std::cout << std::endl;
|
|
||||||
std::cout << "Args:" << std::endl;
|
|
||||||
std::cout << " MESHER: mesher to use from (NETGEN3D, NETGEN2D)" << std::endl;
|
|
||||||
std::cout << " INPUT_MESH_FILE: MED File containing lower-dimension-elements already meshed" << std::endl;
|
|
||||||
std::cout << " SHAPE_FILE: STEP file containing the shape to mesh" << std::endl;
|
|
||||||
std::cout << " HYPO_FILE: Ascii file containint the list of parameters" << std::endl;
|
|
||||||
std::cout << " ELEM_ORIENT_FILE: binary file containing the list of element from INPUT_MESH_FILE associated to the shape and their orientation" << std::endl;
|
|
||||||
std::cout << " NB_THREADS: Number of thread to use for the mesher" << std::endl;
|
|
||||||
std::cout << " NEW_ELEMENT_FILE: (out) contains elements and nodes added by the meshing" << std::endl;
|
|
||||||
std::cout << " OUTPUT_MESH: If !=0 will export mesh into OUTPUT_MESH_FILE " << std::endl;
|
|
||||||
std::cout << " OUTPUT_MESH_FILE: MED File containing the mesh after the run of the mesher" << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
std::string mesher=argv[1];
|
|
||||||
std::string input_mesh_file=argv[2];
|
|
||||||
std::string shape_file=argv[3];
|
|
||||||
std::string hypo_file=argv[4];
|
|
||||||
std::string element_orientation_file=argv[5];
|
|
||||||
int nbThreads=std::stoi(argv[6]);
|
|
||||||
std::string new_element_file=argv[7];
|
|
||||||
bool output_mesh = std::stoi(argv[8]) != 0;
|
|
||||||
std::string output_mesh_file=argv[9];
|
|
||||||
|
|
||||||
if (mesher=="test"){
|
|
||||||
std::cout << "Running tests" << std::endl;
|
|
||||||
test_shape();
|
|
||||||
test_mesh();
|
|
||||||
test_netgen_params();
|
|
||||||
test_netgen3d();
|
|
||||||
} else if (mesher=="NETGEN3D"){
|
|
||||||
auto begin = std::chrono::high_resolution_clock::now();
|
|
||||||
netgen3d(input_mesh_file,
|
|
||||||
shape_file,
|
|
||||||
hypo_file,
|
|
||||||
element_orientation_file,
|
|
||||||
new_element_file,
|
|
||||||
output_mesh,
|
|
||||||
output_mesh_file,
|
|
||||||
nbThreads);
|
|
||||||
auto end = std::chrono::high_resolution_clock::now();
|
|
||||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
|
|
||||||
std::cout << "Time elapsed: " << elapsed.count()*1e-9 << std::endl;
|
|
||||||
} else if (mesher=="NETGEN2D"){
|
|
||||||
netgen2d(input_mesh_file,
|
|
||||||
shape_file,
|
|
||||||
hypo_file,
|
|
||||||
element_orientation_file,
|
|
||||||
new_element_file,
|
|
||||||
output_mesh,
|
|
||||||
output_mesh_file);
|
|
||||||
} else {
|
|
||||||
std::cerr << "Unknown mesher:" << mesher << std::endl;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user