From 51831e696bf39d0d201c60205826b0e355adeff7 Mon Sep 17 00:00:00 2001 From: Boris Martin <boris.martin@uliege.be> Date: Sat, 8 Jul 2023 17:36:12 +0200 Subject: [PATCH] added line acquisition .pos loading --- specific/configuration/line_acquisition.cpp | 79 +++++++++++++-------- 1 file changed, 51 insertions(+), 28 deletions(-) diff --git a/specific/configuration/line_acquisition.cpp b/specific/configuration/line_acquisition.cpp index 005e6ed..32d2216 100644 --- a/specific/configuration/line_acquisition.cpp +++ b/specific/configuration/line_acquisition.cpp @@ -163,43 +163,66 @@ namespace line_acquisition */ _mb.resize(model_size()); _mi.resize(model_size()); + for (unsigned int c = 0; c < model_size(); c++) { - double Remb, Immb; - if - (! - ( - gmshFem.userDefinedParameter(Remb, "Re(mbc"+std::to_string(c)+")") && - gmshFem.userDefinedParameter(Immb, "Im(mbc"+std::to_string(c)+")") - ) - ) + std::string m0_type = "constant"; + std::string suffix = "c" + std::to_string(c); + if (!gmshFem.userDefinedParameter(m0_type, "m0_type" + suffix)) { - throw common::Exception("Background (reference) model parameter (component"+std::to_string(c)+") could not be found."); + msg::warning << "No value of m0_type" << suffix << " found. Using constant (per inclusion) by default." << msg::endl; } - else + if (m0_type == "constant") { - _mb[c] = Remb + im * Immb; - _mc[c] = _mb[c]; - } - ScalarPiecewiseFunction< std::complex< double > > m0; - m0.addFunction(_mb[c],_background[Support::BLK] | _background[Support::BND] | _points); + double Remb, Immb; + if (!( + gmshFem.userDefinedParameter(Remb, "Re(mbc" + std::to_string(c) + ")") && + gmshFem.userDefinedParameter(Immb, "Im(mbc" + std::to_string(c) + ")"))) + { + throw common::Exception("Background (reference) model parameter (component" + std::to_string(c) + ") could not be found."); + } + else + { + _mb[c] = Remb + im * Immb; + _mc[c] = _mb[c]; + } + ScalarPiecewiseFunction<std::complex<double>> m0; + m0.addFunction(_mb[c], _background[Support::BLK] | _background[Support::BND] | _points); - _mi[c].resize(_ni); - for (unsigned int i = 0; i < _ni; i++) - { - double Remi=0., Immi=0.; - if - ( - !(gmshFem.userDefinedParameter(Remi, "Re(mi"+std::to_string(i)+"c"+std::to_string(c)+")") && - gmshFem.userDefinedParameter(Immi, "Im(mi"+std::to_string(i)+"c"+std::to_string(c)+")")) - ) + _mi[c].resize(_ni); + for (unsigned int i = 0; i < _ni; i++) + { + double Remi = 0., Immi = 0.; + if ( + !(gmshFem.userDefinedParameter(Remi, "Re(mi" + std::to_string(i) + "c" + std::to_string(c) + ")") && + gmshFem.userDefinedParameter(Immi, "Im(mi" + std::to_string(i) + "c" + std::to_string(c) + ")"))) + { + throw Exception("Inclusion model parameter could not be found."); + } + _mi[c][i] = Remi + im * Immi; + m0.addFunction(_mi[c][i], _inclusion[i]); + } + _m0.push_back(m0); + } + else if (m0_type == "file.pos") { + std::string path = ""; + if (!gmshFem.userDefinedParameter(path, "m0_path" + suffix)) { - throw Exception("Inclusion model parameter could not be found."); + throw common::Exception("Path to subsurface data could not be found."); } - _mi[c][i] = Remi + im * Immi; - m0.addFunction(_mi[c][i],_inclusion[i]); + + gmsh::merge(path + suffix + ".pos"); + // Fix for weird tags when loading .pos files. + std::vector<int> tags; + gmsh::view::getTags(tags); + auto view = tags.back(); + ScalarFunction<std::complex<double>> mpos = probeScalarView<std::complex<double>>(view); + + _m0.push_back(mpos); + } + else { + throw Exception("Invalid model type: " + m0_type); } - _m0.push_back(m0); } } void Configuration::mesh() const -- GitLab