/* This file is part of Lemma, a geophysical modelling and inversion API. * More information is available at http://lemmasoftware.org */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /** * @file * @date 08/07/2014 04:16:25 PM * @version $Id$ * @author Trevor Irons (ti) * @email Trevor.Irons@xri-geo.com * @copyright Copyright (c) 2014, XRI Geophysics, LLC * @copyright Copyright (c) 2014, Trevor Irons */ #include #include #include #include #include #include #include #include #include #include #include "DCSurvey.h" #include "FEM4EllipticPDE.h" #ifdef HAVE_YAMLCPP #include "yaml-cpp/yaml.h" #endif using namespace Lemma; int main(int argc, char**argv) { std::cout << "Mesh processing routine\n"; if (argc<4) { std::cout << "usage:\n" << "./utVTKEdge mesh.vtu input.yaml results.vtu" << std::endl; exit(EXIT_SUCCESS); } vtkUnstructuredGrid* uGrid = vtkUnstructuredGrid::New(); std::string fn = argv[1]; if(fn.substr(fn.find_last_of(".") + 1) == "vtk") { vtkGenericDataObjectReader* Reader = vtkGenericDataObjectReader::New(); Reader->SetFileName(argv[1]); Reader->Update(); if(Reader->IsFileUnstructuredGrid()) { std::cout << "Found Unstructured grid legacy file" << std::endl; uGrid = Reader->GetUnstructuredGridOutput(); } else { std::cerr << "Unknown legacy format"; exit(EXIT_FAILURE); } } else { vtkXMLUnstructuredGridReader* Reader = vtkXMLUnstructuredGridReader::New(); std::cout << "Reading" << argv[1] << std::endl; Reader->SetFileName(argv[1]); Reader->Update(); uGrid = Reader->GetOutput(); } int nc = uGrid->GetNumberOfCells() ; int nn = uGrid->GetNumberOfPoints() ; std::cout << "Processing grid with nodes=" << nn << "\t cells=" << nc << "\n"; std::ifstream ifstr(argv[2]); //std::vector nodes = YAML::LoadAll(ifstr); YAML::Node nodes = YAML::Load(ifstr); auto Survey = DCSurvey::DeSerialize(nodes); //std::cout << *Survey << std::endl; //////////////////////////////////////////// // Solve auto Solver = FEM4EllipticPDE::NewSP(); //Solver->SetGFunction(implG); //Solver->SetGFunction(Magnet); //Solver->SetSigmaFunction(implSigma); //Solver->SetBoundaryStep(.05); Solver->SetGrid(uGrid); Solver->SetupDC( Survey.get(), 0 ); Solver->Solve( argv[3] ); //Solver->SetGrid(rGrid); //Solver->Solve(argv[3]); exit(EXIT_SUCCESS); }