@@ -68,62 +68,38 @@ AlgorithmOutput GetFieldDataAlgo::run_generic(const AlgorithmInput& input) const
6868// / Function call to convert data from Field into Matrix data
6969DenseMatrixHandle GetFieldDataAlgo::run (FieldHandle input_field) const
7070{
71- #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
72- algo_start (" GetFieldData" );
73-
74- // / Check whether we have a field.
75- if (input.get_rep () == 0 )
76- {
77- error (" No input source field" );
78- algo_end (); return (false );
79- }
80-
81- // / Construct a class with all the type information of this field
82- FieldInformation fi (input);
83-
84- // / Check whether we have data
85- if (fi.is_nodata ())
71+ if (!input_field)
8672 {
87- error (" Field does not contain any data" );
88- algo_end (); return (false );
73+ THROW_ALGORITHM_INPUT_ERROR (" No input field was provided" );
8974 }
90-
91- // / Depending on the data type select a sub algorithm
92- if (fi.is_scalar ())
93- return (GetScalarFieldDataV (this ,input,output));
9475
95- else if (fi.is_vector ())
96- return (GetVectorFieldDataV (this ,input,output));
76+ DenseMatrixHandle output;
9777
98- else if (fi.is_tensor ())
99- return (GetTensorFieldDataV (this ,input,output));
100-
101- error (" Unknown data type" );
102- algo_end (); return (false );
103- #endif
104-
105- DenseMatrixHandle output;
106-
10778 VField* vfield1 = input_field->vfield ();
10879
10980 // / Check whether we have data
110- if (!input_field || ! vfield1)
81+ if (! vfield1)
11182 {
112- THROW_ALGORITHM_INPUT_ERROR (" Could not obtain input field " );
83+ THROW_ALGORITHM_INPUT_ERROR (" Could not obtain VField interface " );
11384 }
114-
115- if (vfield1->is_scalar ())
116- return (GetScalarFieldDataV (input_field));
85+
86+ if (vfield1->is_nodata ())
87+ {
88+ THROW_ALGORITHM_INPUT_ERROR (" Invalid input field (no data)" );
89+ }
90+
91+ if (vfield1->is_scalar ())
92+ return (GetScalarFieldDataV (input_field));
11793 else
118- if (vfield1->is_vector ())
119- return (GetVectorFieldDataV (input_field));
94+ if (vfield1->is_vector ())
95+ return (GetVectorFieldDataV (input_field));
12096 else
121- if (vfield1->is_tensor ())
122- return (GetTensorFieldDataV (input_field));
123- else
124- {
125- THROW_ALGORITHM_INPUT_ERROR (" Unknown field data type!" );
126- }
97+ if (vfield1->is_tensor ())
98+ return (GetTensorFieldDataV (input_field));
99+ else
100+ {
101+ THROW_ALGORITHM_INPUT_ERROR (" Unknown field data type!" );
102+ }
127103
128104}
129105
@@ -150,7 +126,7 @@ DenseMatrixHandle GetFieldDataAlgo::GetScalarFieldDataV(FieldHandle& input) cons
150126 {
151127 vfield->get_value ((*output)(idx, 0 ),idx);
152128 }
153- #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
129+ #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
154130 if (vfield->basis_order () == 2 )
155131 {
156132 vfield->vmesh ()->synchronize (Mesh::EDGES_E);
@@ -159,7 +135,7 @@ DenseMatrixHandle GetFieldDataAlgo::GetScalarFieldDataV(FieldHandle& input) cons
159135 vfield->get_evalue ((*output)(idx, 0 ),idx);
160136 }
161137 }
162- #endif
138+ #endif
163139
164140 return output;
165141}
0 commit comments