Galerkin FEM for elliptic PDEs
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ResampleWithDataset.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 01/27/2016 01:24:24 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email tirons@egi.utah.edu
  14. * @copyright Copyright (c) 2016, University of Utah
  15. * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
  16. */
  17. #include <vtkProbeFilter.h>
  18. #include <vtkSTLReader.h>
  19. #include <vtkUnstructuredGrid.h>
  20. #include <vtkUnstructuredGridReader.h>
  21. #include <vtkUnstructuredGridWriter.h>
  22. #include <vtkGenericDataObjectReader.h>
  23. #include <vtkXMLUnstructuredGridReader.h>
  24. #include <vtkXMLUnstructuredGridWriter.h>
  25. #include <vtkDoubleArray.h>
  26. #include <vtkPointData.h>
  27. #include <cmath>
  28. #include <Eigen/Core>
  29. int main(int argc, char**argv) {
  30. std::cout << "Mesh boundary assigment routine\n";
  31. if (argc<4) {
  32. std::cout << "usage:\n" << "./ResampleWithDataset inMesh.vtu boundaries.stl outG.vtu" << std::endl;
  33. exit(EXIT_SUCCESS);
  34. }
  35. vtkUnstructuredGrid* uGrid;// = vtkUnstructuredGrid::New();
  36. std::string fn = argv[1];
  37. if(fn.substr(fn.find_last_of(".") + 1) == "vtk") {
  38. vtkGenericDataObjectReader* Reader = vtkGenericDataObjectReader::New();
  39. Reader->SetFileName(argv[1]);
  40. Reader->Update();
  41. if(Reader->IsFileUnstructuredGrid()) {
  42. std::cout << "Found Unstructured grid legacy file" << std::endl;
  43. uGrid = Reader->GetUnstructuredGridOutput();
  44. } else {
  45. std::cerr << "Unknown legacy format";
  46. exit(EXIT_FAILURE);
  47. }
  48. } else {
  49. vtkXMLUnstructuredGridReader* Reader = vtkXMLUnstructuredGridReader::New();
  50. std::cout << "Reading" << argv[1] << std::endl;
  51. Reader->SetFileName(argv[1]);
  52. Reader->Update();
  53. uGrid = Reader->GetOutput();
  54. }
  55. int nc = uGrid->GetNumberOfCells() ;
  56. int nn = uGrid->GetNumberOfPoints() ;
  57. std::cout << "Processing grid with nodes=" << nn << "\t cells=" << nc << "\n";
  58. vtkSTLReader* Stencil = vtkSTLReader::New();
  59. Stencil->SetFileName(argv[2]);
  60. Stencil->Update();
  61. vtkProbeFilter* Resample = vtkProbeFilter::New();
  62. //Resample->SetSourceData( uGrid );
  63. //Resample->SetInputData( Stencil->GetOutput() );
  64. Resample->SetInputData( uGrid );
  65. Resample->SetSourceData( Stencil->GetOutput() );
  66. Resample->SpatialMatchOn();
  67. Resample->SetValidPointMaskArrayName("HomogeneousDirichlet");
  68. Resample->Update();
  69. std::cout << *Resample << std::endl;
  70. vtkXMLUnstructuredGridWriter* Writer = vtkXMLUnstructuredGridWriter::New();
  71. Writer->SetInputData( Resample->GetOutput() );
  72. Writer->SetFileName( argv[3] );
  73. Writer->Write();
  74. Writer->Delete();
  75. Resample->Delete();
  76. //Reader->Delete();
  77. Stencil->Delete();
  78. //std::cout << *Stencil << std::endl;
  79. }