# ComponentVoxel : How to have access to the values of the magnetic field

**URL:** <https://root-forum.cern.ch/t/componentvoxel-how-to-have-access-to-the-values-of-the-magnetic-field/34896>\
**Category:** Garfield++\
**Created:** [June 28, 2019, 8:15am UTC](https://root-forum.cern.ch/t/componentvoxel-how-to-have-access-to-the-values-of-the-magnetic-field/34896 "2019-06-28T08:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kali95](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@Kali95](https://root-forum.cern.ch/u/Kali95)\
**Post date:** [June 28, 2019, 8:15am UTC](https://root-forum.cern.ch/t/componentvoxel-how-to-have-access-to-the-values-of-the-magnetic-field/34896/1 "2019-06-28T08:15:44Z")

</div>

Hello everyone,

I created a parallelepipd magnetic field and now I try to have access to the magnetic field in a random point inside my magnetic volume (after interpolation). However, I cannot find any function for that, for example a function which could have the coordinates (x,y,z)in arguments and which could return either an error message if is outside the volume or outside the mesh if it is not interpolated either the value of the magnetic field.

Do you know a such function ?

Here is my code, which lines could I add for that ?

```auto
const unsigned int nx=13;
	const unsigned int ny=13;
	const unsigned int nz=251;
	const double xmin=-240;
	const double xmax=240;
	const double ymin=-240;
	const double ymax=240;
	const double zmin=-5000;
	const double zmax=5000;

	const std::string filename = "data_test.txt";
	const std::string format= "XYZ";
	ComponentVoxel *mesh=new ComponentVoxel();
	mesh->SetMesh(nx,ny,nz,xmin,xmax,ymin,ymax,zmin,zmax);
	mesh->LoadMagneticField(filename,format,1,1);
	mesh->EnableInterpolation(true);

```

Thank you in advance for your answers,

Kali95

---

<div class="post-metadata">

**Author:** ![Kali95](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@Kali95](https://root-forum.cern.ch/u/Kali95)\
**Post date:** [June 28, 2019, 8:20am UTC](https://root-forum.cern.ch/t/componentvoxel-how-to-have-access-to-the-values-of-the-magnetic-field/34896/2 "2019-06-28T08:20:24Z")

</div>

I forgot to add the file from where I am taking the datas :

[data\_test.tar.gz](https://root-forum.cern.ch/uploads/default/original/3X/7/6/765099064294b0f642169b2fc58b526d0ce17489.gz) (1.1 MB)

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 12, 2019, 8:20am UTC](https://root-forum.cern.ch/t/componentvoxel-how-to-have-access-to-the-values-of-the-magnetic-field/34896/3 "2019-07-12T08:20:26Z")

</div>

Closed on July 12, 2019, 8:20am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
