Skip to content

Commit 55a3643

Browse files
committed
refactor how shape functions are selected in the input file
there used to be a flag quadratic_shape_function_enabled now the user sets shape_function_type to one of the types available
1 parent 0cb446a commit 55a3643

File tree

8 files changed

+55
-27
lines changed

8 files changed

+55
-27
lines changed

src/api/DICe_api.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ DICE_LIB_DLL_EXPORT const int_t dice_correlate(scalar_t points[], int_t n_points
113113
// call set_params on the schema in case the parameter have changed:
114114
if(!initialized||update_params)
115115
schema.set_params(params);
116-
TEUCHOS_TEST_FOR_EXCEPTION(schema.quadratic_shape_function_enabled(),std::runtime_error,"Error, cannot use quadratic shape function for the api routines");
116+
TEUCHOS_TEST_FOR_EXCEPTION(schema.shape_function_type()!=DICe::AFFINE_SF,std::runtime_error,"Error, can only use AFFINE shape function for the api routines");
117117

118118

119119
initialized = true;
@@ -258,7 +258,7 @@ DICE_LIB_DLL_EXPORT const int_t dice_correlate_conformal(scalar_t points[],
258258
schema.local_field_value(i,DICe::field_enums::BETA_FS) = points[i*DICE_API_STRIDE + 7];
259259
schema.local_field_value(i,DICe::field_enums::STATUS_FLAG_FS) = points[i*DICE_API_STRIDE + 8];
260260
}
261-
TEUCHOS_TEST_FOR_EXCEPTION(schema.quadratic_shape_function_enabled(),std::runtime_error,"Error, cannot use quadratic shape function for the api routines");
261+
TEUCHOS_TEST_FOR_EXCEPTION(schema.shape_function_type()!=DICe::AFFINE_SF,std::runtime_error,"Error, can only use AFFINE shape function for the api routines");
262262

263263
schema.execute_correlation();
264264

src/base/DICe.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const char* const convert_cine_to_8_bit = "convert_cine_to_8_bit";
166166
/// String parameter name
167167
const char* const initial_condition_file = "initial_condition_file";
168168
/// String parameter name
169-
const char* const enable_quadratic_shape_function = "enable_quadratic_shape_function";
169+
const char* const shape_function_type = "shape_function_type";
170170
/// String parameter name
171171
const char* const enable_translation = "enable_translation";
172172
/// String parameter name
@@ -345,7 +345,7 @@ enum Analysis_Type {
345345
NO_SUCH_ANALYSIS_TYPE
346346
};
347347

348-
/// Projection method
348+
/// Global formulation
349349
enum Global_Formulation {
350350
HORN_SCHUNCK=0,
351351
MIXED_HORN_SCHUNCK,
@@ -409,6 +409,22 @@ const static char * initializationMethodStrings[] = {
409409
"INITIALIZATION_METHOD_NOT_APPLICABLE"
410410
};
411411

412+
/// Shape function type
413+
enum Shape_Function_Type {
414+
AFFINE_SF=0,
415+
QUADRATIC_SF,
416+
PROJECTION_SF,
417+
// DON'T ADD ANY BELOW MAX
418+
MAX_SF,
419+
NO_SUCH_SF
420+
};
421+
422+
const static char * shapeFunctionTypeStrings[] = {
423+
"AFFINE",
424+
"QUADRATIC",
425+
"PROJECTION"
426+
};
427+
412428
/// Optimization method
413429
enum Optimization_Method {
414430
SIMPLEX=0,
@@ -901,10 +917,12 @@ const Correlation_Parameter initial_condition_file_param(initial_condition_file,
901917
true,
902918
"Denotes a file to read the solution from as the initial condition");
903919
/// Correlation parameter and properties
904-
const Correlation_Parameter enable_quadratic_shape_function_param(enable_quadratic_shape_function,
905-
BOOL_PARAM,
920+
const Correlation_Parameter shape_function_type_param(shape_function_type,
921+
STRING_PARAM,
906922
true,
907-
"Enables the quadratic shape function degrees of freedom (all components are activiated and individual components like rotation or shear cannot be disabled)");
923+
"Determines what type of shape function is used",
924+
shapeFunctionTypeStrings,
925+
MAX_SF);
908926
/// Correlation parameter and properties
909927
const Correlation_Parameter enable_translation_param(enable_translation,
910928
BOOL_PARAM,
@@ -1145,7 +1163,7 @@ const Correlation_Parameter valid_correlation_params[num_valid_correlation_param
11451163
compute_image_gradients_param,
11461164
gauss_filter_images_param,
11471165
initial_condition_file_param,
1148-
enable_quadratic_shape_function_param,
1166+
shape_function_type_param,
11491167
enable_translation_param,
11501168
enable_rotation_param,
11511169
enable_normal_strain_param,

src/base/DICe_LocalShapeFunction.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ DICE_LIB_DLL_EXPORT
5050
Teuchos::RCP<Local_Shape_Function> shape_function_factory(Schema * schema){
5151
if(!schema){
5252
return Teuchos::rcp(new Affine_Shape_Function(schema));
53-
}
54-
else if(schema->quadratic_shape_function_enabled()){
53+
}else if(schema->shape_function_type()==DICe::AFFINE_SF){
54+
return Teuchos::rcp(new Affine_Shape_Function(schema));
55+
}else if(schema->shape_function_type()==DICe::QUADRATIC_SF){
5556
return Teuchos::rcp(new Quadratic_Shape_Function());
5657
}else{
57-
return Teuchos::rcp(new Affine_Shape_Function(schema));
58+
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error, invalid shape function type");
5859
}
5960
}
6061

src/core/DICe_Initializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ Field_Value_Initializer::initial_guess(const int_t subset_gid,
386386
return INITIALIZE_USING_PREVIOUS_FRAME_SUCCESSFUL;
387387
else{
388388
// if using a neighbor's value, the parameters have to be adjusted to account
389-
// for the change in centroids
390-
if(schema_->quadratic_shape_function_enabled()){
389+
// for the change in centroids for the quadratic shape function
390+
if(schema_->shape_function_type()==DICe::QUADRATIC_SF){
391391
scalar_t cx = schema_->global_field_value(subset_gid,SUBSET_COORDINATES_X_FS);
392392
scalar_t cy = schema_->global_field_value(subset_gid,SUBSET_COORDINATES_Y_FS);
393393
scalar_t cx_neigh = schema_->global_field_value(sid,SUBSET_COORDINATES_X_FS);

src/core/DICe_ParameterUtilities.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ const std::string to_string(Optimization_Method in){
123123
return optimizationMethodStrings[in];
124124
}
125125
DICE_LIB_DLL_EXPORT
126+
const std::string to_string(Shape_Function_Type in){
127+
assert(in < MAX_SF);
128+
return shapeFunctionTypeStrings[in];
129+
}
130+
DICE_LIB_DLL_EXPORT
126131
const std::string to_string(Interpolation_Method in){
127132
assert(in < MAX_INTERPOLATION_METHOD);
128133
return interpolationMethodStrings[in];
@@ -294,7 +299,7 @@ DICE_LIB_DLL_EXPORT void tracking_default_params(Teuchos::ParameterList * defau
294299
defaultParams->set(DICe::projection_method,DICe::DISPLACEMENT_BASED);
295300
defaultParams->set(DICe::disp_jump_tol,8.0);
296301
defaultParams->set(DICe::theta_jump_tol,0.1);
297-
defaultParams->set(DICe::enable_quadratic_shape_function,false);
302+
defaultParams->set(DICe::shape_function_type,DICe::AFFINE_SF);
298303
defaultParams->set(DICe::enable_translation,true);
299304
defaultParams->set(DICe::enable_rotation,true);
300305
defaultParams->set(DICe::enable_normal_strain,false);
@@ -355,7 +360,7 @@ DICE_LIB_DLL_EXPORT void dice_default_params(Teuchos::ParameterList * defaultPa
355360
defaultParams->set(DICe::use_search_initialization_for_failed_steps,false);
356361
defaultParams->set(DICe::disp_jump_tol,10000.0);
357362
defaultParams->set(DICe::theta_jump_tol,100.0);
358-
defaultParams->set(DICe::enable_quadratic_shape_function,false);
363+
defaultParams->set(DICe::shape_function_type,DICe::AFFINE_SF);
359364
defaultParams->set(DICe::enable_translation,true);
360365
defaultParams->set(DICe::enable_rotation,false);
361366
defaultParams->set(DICe::enable_normal_strain,false);

src/core/DICe_ParameterUtilities.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ const std::string to_string(Initialization_Method in);
8383
DICE_LIB_DLL_EXPORT
8484
const std::string to_string(Optimization_Method in);
8585

86+
/// Convert a DICe::Shape_Function_Type to string
87+
DICE_LIB_DLL_EXPORT
88+
const std::string to_string(Shape_Function_Type in);
89+
8690
/// Convert a DICe::Interpolation_Method to string
8791
DICE_LIB_DLL_EXPORT
8892
const std::string to_string(Interpolation_Method in);

src/core/DICe_Schema.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,8 +552,8 @@ Schema::set_params(const Teuchos::RCP<Teuchos::ParameterList> & params){
552552
enable_normal_strain_ = diceParams->get<bool>(DICe::enable_normal_strain);
553553
TEUCHOS_TEST_FOR_EXCEPTION(!diceParams->isParameter(DICe::enable_shear_strain),std::runtime_error,"");
554554
enable_shear_strain_ = diceParams->get<bool>(DICe::enable_shear_strain);
555-
TEUCHOS_TEST_FOR_EXCEPTION(!diceParams->isParameter(DICe::enable_quadratic_shape_function),std::runtime_error,"");
556-
enable_quadratic_shape_function_ = diceParams->get<bool>(DICe::enable_quadratic_shape_function);
555+
TEUCHOS_TEST_FOR_EXCEPTION(!diceParams->isParameter(DICe::shape_function_type),std::runtime_error,"");
556+
shape_function_type_ = diceParams->get<Shape_Function_Type>(DICe::shape_function_type);
557557
TEUCHOS_TEST_FOR_EXCEPTION(!diceParams->isParameter(DICe::output_deformed_subset_images),std::runtime_error,"");
558558
output_deformed_subset_images_ = diceParams->get<bool>(DICe::output_deformed_subset_images);
559559
TEUCHOS_TEST_FOR_EXCEPTION(!diceParams->isParameter(DICe::output_deformed_subset_intensity_images),std::runtime_error,"");
@@ -935,14 +935,14 @@ Schema::initialize(const Teuchos::RCP<Teuchos::ParameterList> & input_params,
935935
if(proc_rank==0) DEBUG_MSG("Seeding the displacement solution for subset " << subset_id << " with ux: " <<
936936
global_field_value(subset_id,SUBSET_DISPLACEMENT_X_FS) << " uy: " << global_field_value(subset_id,SUBSET_DISPLACEMENT_Y_FS));
937937
if(subset_info->normal_strain_map->find(roi_id)!=subset_info->normal_strain_map->end()){
938-
TEUCHOS_TEST_FOR_EXCEPTION(enable_quadratic_shape_function_,std::runtime_error,"Error, seeds can't be used with the quadratic shape function enabled");
938+
TEUCHOS_TEST_FOR_EXCEPTION(shape_function_type_!=DICe::AFFINE_SF,std::runtime_error,"Error, seeds can only be used with the affine shape function");
939939
global_field_value(subset_id,NORMAL_STRETCH_XX_FS) = subset_info->normal_strain_map->find(roi_id)->second.first;
940940
global_field_value(subset_id,NORMAL_STRETCH_YY_FS) = subset_info->normal_strain_map->find(roi_id)->second.second;
941941
if(proc_rank==0) DEBUG_MSG("Seeding the normal strain solution for subset " << subset_id << " with ex: " <<
942942
global_field_value(subset_id,NORMAL_STRETCH_XX_FS) << " ey: " << global_field_value(subset_id,NORMAL_STRETCH_YY_FS));
943943
}
944944
if(subset_info->shear_strain_map->find(roi_id)!=subset_info->shear_strain_map->end()){
945-
TEUCHOS_TEST_FOR_EXCEPTION(enable_quadratic_shape_function_,std::runtime_error,"Error, seeds can't be used with the quadratic shape function enabled");
945+
TEUCHOS_TEST_FOR_EXCEPTION(shape_function_type_!=DICe::AFFINE_SF,std::runtime_error,"Error, seeds can only be used with the affine shape function");
946946
global_field_value(subset_id,SHEAR_STRETCH_XY_FS) = subset_info->shear_strain_map->find(roi_id)->second;
947947
if(proc_rank==0) DEBUG_MSG("Seeding the shear strain solution for subset " << subset_id << " with gamma_xy: " <<
948948
global_field_value(subset_id,SHEAR_STRETCH_XY_FS));
@@ -3281,7 +3281,7 @@ Output_Spec::Output_Spec(Schema * schema,
32813281
field_names_.push_back(SUBSET_DISPLACEMENT_X_FS.get_name_label());
32823282
field_names_.push_back(SUBSET_DISPLACEMENT_Y_FS.get_name_label());
32833283
field_names_.push_back(ROTATION_Z_FS.get_name_label());
3284-
if(!schema->quadratic_shape_function_enabled()){
3284+
if(schema->shape_function_type()==DICe::AFFINE_SF){
32853285
field_names_.push_back(NORMAL_STRETCH_XX_FS.get_name_label());
32863286
field_names_.push_back(NORMAL_STRETCH_YY_FS.get_name_label());
32873287
field_names_.push_back(SHEAR_STRETCH_XY_FS.get_name_label());
@@ -3411,7 +3411,7 @@ Output_Spec::write_info(std::FILE * file,
34113411
fprintf(file,"*** Guess initialization method: %s\n",init_method.c_str());
34123412
fprintf(file,"*** Seed location: N/A\n");
34133413
fprintf(file,"*** Shape functions: ");
3414-
if(schema_->quadratic_shape_function_enabled()){
3414+
if(schema_->shape_function_type()==DICe::QUADRATIC_SF){
34153415
fprintf(file,"quadratic (A,B,C,D,E,F,G,H,I,J,K,L)");
34163416
}else{
34173417
if(schema_->translation_enabled())

src/core/DICe_Schema.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,8 @@ Schema {
741741

742742
// shape function controls:
743743
/// Returns true if all quadratic shape functions are enabled
744-
bool quadratic_shape_function_enabled() const {
745-
return enable_quadratic_shape_function_;
744+
Shape_Function_Type shape_function_type() const {
745+
return shape_function_type_;
746746
}
747747

748748
/// Returns true if translation shape functions are enabled
@@ -802,8 +802,8 @@ Schema {
802802
}
803803

804804
/// Enable translation shape functions
805-
void enable_quadratic_shape_function(const bool flag){
806-
enable_quadratic_shape_function_ = flag;
805+
void set_shape_function_type(const Shape_Function_Type sft){
806+
shape_function_type_ = sft;
807807
}
808808

809809
/// Enable translation shape functions
@@ -1159,8 +1159,8 @@ Schema {
11591159
Projection_Method projection_method_;
11601160
/// Analysis type
11611161
Analysis_Type analysis_type_;
1162-
/// Enable the quadratic shape functions all together rather than individual components
1163-
bool enable_quadratic_shape_function_;
1162+
/// Shape function type
1163+
Shape_Function_Type shape_function_type_;
11641164
/// Enable translation
11651165
bool enable_translation_;
11661166
/// Enable rotation

0 commit comments

Comments
 (0)