@@ -98,6 +98,41 @@ Laser::GetEnvelopeFromFileHelper (amrex::Geometry laser_geom_3D) {
9898
9999 auto mesh = iteration.meshes [m_file_envelope_name];
100100
101+ // Check that we are reading a normalized vector potential and not an electric field
102+ const std::array<double , 7 > units_file = mesh.unitDimension ();
103+ const std::array<double , 7 > units_norm_potential{0 ., 0 ., 0 ., 0 ., 0 ., 0 ., 0 .};
104+ const std::array<double , 7 > units_electric_field{1 ., 1 ., -3 ., -1 ., 0 ., 0 ., 0 .};
105+ const std::string help_msg = " Make sure to store the normalized vector potential, "
106+ " set the Attribute 'envelopeField' to 'normalized_vector_potential' and "
107+ " unitDimension to '" + amrex::ToString (units_norm_potential) + " '. "
108+ " If you are using LASY to generate the laser, pass 'save_as_vector_potential=True' "
109+ " to laser.write_to_file() or write_to_openpmd_file()" ;
110+
111+ if (mesh.containsAttribute (" envelopeField" )) {
112+ const std::string field_type = mesh.getAttribute (" envelopeField" ).get <std::string>();
113+ if (field_type == " electric_field" ) {
114+ amrex::Abort (" Attribute 'envelopeField' in file '" + m_input_file_path +
115+ " ' is set to 'electric_field' which is not compatible with HiAPCE++. " +
116+ help_msg
117+ );
118+ } else if (field_type != " normalized_vector_potential" ) {
119+ amrex::AllPrint () << " WARNING: Attribute 'envelopeField' in file '"
120+ << m_input_file_path << " ' is set to '" << field_type << " ' which is not "
121+ " recognized. " << help_msg << ' \n ' ;
122+ }
123+ }
124+
125+ if (units_file == units_electric_field) {
126+ amrex::Abort (" unitDimension '" + amrex::ToString (units_file) + " ' in file '"
127+ + m_input_file_path + " ' is that of an electric field which is not compatible "
128+ " with HiAPCE++. " + help_msg
129+ );
130+ } else if (units_file != units_norm_potential) {
131+ amrex::AllPrint () << " WARNING: unitDimension '" << amrex::ToString (units_file)
132+ << " ' in file '" << m_input_file_path << " ' is not recognized. "
133+ << help_msg << ' \n ' ;
134+ }
135+
101136 AMREX_ALWAYS_ASSERT_WITH_MESSAGE (
102137 mesh.containsAttribute (" angularFrequency" ),
103138 " Could not find Attribute 'angularFrequency' of iteration "
0 commit comments