Incomplete type error when creating non-uniform magnetic field

I’ve been working on creating a non-uniform magnetic field in GEANT. It has constant direction but the magnitude changes. I’ve mostly been following the tutorial in the user guide and looking at the code in example B2 and B5. The code I have written to handle the B-Field is

Jovian_B_field = new JovianField(); G4FieldManager* globalFieldMgr = G4TransportationManager::GetTransportationManager() -> GetFieldManager(); globalFieldMgr -> SetDetectorField(Jovian_B_field); globalFieldMgr -> CreateChordFinder(Jovian_B_field);

And when this runs I get the error:

member access into incomplete type 'G4FieldManager'

I assume this is something to do with the way I’ve written my custom B-Field but I am not sure how to do it properly since none of the examples quite illustrate what I’m looking for. In particular, I’m pretty confident that I’ve built my constructor incorrectly so any guidance there would be appreciated. Ive attached the source and header files for both my detector construction files and my field definition files. (6.4 KB) (574 Bytes) ConstructJupiter.hh (2.6 KB) JovianField.hh (519 Bytes)

Thank you to anyone who can provide insight, I am at a major loss

I don’t know about the run-time error, but I’d just like to say you can’t have a non-uniform field that does not change direction in places - Maxwell’s equations, field lines and all that.

Yes, I am aware that a real B-field can not exclusively change magnitude however I was hoping the GEANT would let my grotesque approximation slide since the scale I’m looking at features very little change in B-field direction. Maybe GEANT will, at some point, tell me I’m not allowed to cheat Maxwell like that but Im pretty sure that my run-time error has more to do with an improper implementation of G4MagneticField than a physics issue

Hi Gabriel,

You are correct that a simple example demonstrating how to use a user created field class is missing. I will try to create one - or better revise examples / extended / field / field01 to demonstrate this, instead of its complex current scenario.

I have tried to integrate your field class and detector constructor class into a simple Geant4 examples (in fact field01). After some adaptation I found a couple of issues, which I believe explain your problem. In addition I have some suggestions for structuring your Detector Construction class, which will make it a bit more future-compatible (in fact it will help if you ever need to use multi-threading.)

Here is what I found:

  • a compilation error in your construction class: you should include “G4FieldManager.hh”
    This is causing the compilation error which you reported.
    An error like this which occurs during compilation, is not a “run time” error. ( Those happen when the program itself is executing. )

  • The two gasses you use, hydrogen and helium, are not found as the source code is written. Please use the name “G4_H” for hydrogen, and “G4_He” for helium. These materials were found, whereas “H” and “He” were not found when I ran your construction class.

  • Instead of constructing the Sensitive Detector and Field in the ‘Construct’ method, please construct them in a dedicated ConstructSDandField method. That would allow them to be created separately on any future thread.

This is demonstrated in field01 in the method
void F01DetectorConstruction::ConstructSDandField()

I hope that these suggestions help you create your setup correctly.

Best regards,
John Apostolakis