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.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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->Update();
  68. std::cout << *Resample << std::endl;
  69. vtkXMLUnstructuredGridWriter* Writer = vtkXMLUnstructuredGridWriter::New();
  70. Writer->SetInputData( Resample->GetOutput() );
  71. Writer->SetFileName( argv[3] );
  72. Writer->Write();
  73. Writer->Delete();
  74. Resample->Delete();
  75. //Reader->Delete();
  76. Stencil->Delete();
  77. //std::cout << *Stencil << std::endl;
  78. }