Skip to content

Commit

Permalink
trdotn test
Browse files Browse the repository at this point in the history
  • Loading branch information
anshchaube committed Dec 11, 2023
1 parent e07e0d7 commit 9109e82
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/base/CardinalEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ enum NekFieldEnum
scalar02,
scalar03,
wall_shear,
// traction,
traction,
traction_x,
traction_y,
traction_z,
Expand Down
2 changes: 1 addition & 1 deletion src/base/CardinalEnums.C
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ getNekFieldEnum()
{
return MooseEnum(
"velocity_component velocity_x velocity_y velocity_z velocity temperature"
" pressure scalar01 scalar02 scalar03 wall_shear traction_x traction_y traction_z"
" pressure scalar01 scalar02 scalar03 wall_shear traction traction_x traction_y traction_z"
" ros_s11 ros_s22 ros_s33 ros_s12 ros_s23 ros_s13 unity");
}

Expand Down
48 changes: 31 additions & 17 deletions src/base/NekInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ initializeRateOfStrainTensor()
void
initializeTraction()
{
nekrs::_traction = (double *)calloc(3*velocityFieldOffset(), sizeof(double));
nekrs::_traction = (double *)calloc(4*velocityFieldOffset(), sizeof(double)); //TODO: finalize size
}

void
Expand Down Expand Up @@ -1509,18 +1509,32 @@ computeTraction(double * traction, const nek_mesh::NekMeshEnum pp_mesh)
int vol_id = mesh->vmapM[offset + v];
int surf_offset = mesh->Nsgeo * (offset + v);

double nx = sgeo[surf_offset + NXID];
double ny = sgeo[surf_offset + NYID];
double nz = sgeo[surf_offset + NZID];
//TODO: explain reasoning below
traction[nrs_offset*0 + vol_id] = Tau_ij[0*nrs_offset + vol_id] * sgeo[surf_offset + NXID]
+ Tau_ij[3*nrs_offset + vol_id] * sgeo[surf_offset + NYID]
+ Tau_ij[5*nrs_offset + vol_id] * sgeo[surf_offset + NZID];
traction[nrs_offset*0 + vol_id] = Tau_ij[0*nrs_offset + vol_id] * nx
+ Tau_ij[3*nrs_offset + vol_id] * ny
+ Tau_ij[5*nrs_offset + vol_id] * nz;

traction[nrs_offset*1 + vol_id] = Tau_ij[3*nrs_offset + vol_id] * sgeo[surf_offset + NXID]
+ Tau_ij[1*nrs_offset + vol_id] * sgeo[surf_offset + NYID]
+ Tau_ij[4*nrs_offset + vol_id] * sgeo[surf_offset + NZID];
traction[nrs_offset*1 + vol_id] = Tau_ij[3*nrs_offset + vol_id] * nx
+ Tau_ij[1*nrs_offset + vol_id] * ny
+ Tau_ij[4*nrs_offset + vol_id] * nz;

traction[nrs_offset*2 + vol_id] = Tau_ij[5*nrs_offset + vol_id] * sgeo[surf_offset + NXID]
+ Tau_ij[4*nrs_offset + vol_id] * sgeo[surf_offset + NYID]
+ Tau_ij[2*nrs_offset + vol_id] * sgeo[surf_offset + NZID];
traction[nrs_offset*2 + vol_id] = Tau_ij[5*nrs_offset + vol_id] * nx
+ Tau_ij[4*nrs_offset + vol_id] * ny
+ Tau_ij[2*nrs_offset + vol_id] * nz;

double t_dot_n = traction[0*nrs_offset + vol_id] * nx // TODO: decide whether to keep
+ traction[1*nrs_offset + vol_id] * ny
+ traction[2*nrs_offset + vol_id] * nz;

double tx = traction[nrs_offset*0 + vol_id];
double ty = traction[nrs_offset*1 + vol_id];
double tz = traction[nrs_offset*2 + vol_id];

traction[nrs_offset*3 + vol_id] = (t_dot_n/t_dot_n) *
std::sqrt( tx * tx + ty * ty + tz * tz);
}
}
}
Expand Down Expand Up @@ -1758,7 +1772,7 @@ double
traction(const int id)
{
nrs_t * nrs = (nrs_t *)nrsPtr();
return _traction[id];
return _traction[id+ 3 * nrs->fieldOffset]; //TODO: decide whether to keep this or not
}

double
Expand Down Expand Up @@ -1933,9 +1947,9 @@ double (*solutionPointer(const field::NekFieldEnum & field))(int)
case field::wall_shear:
f = &wall_shear;
break;
// case field::traction:
// f = &traction;
// break;
case field::traction:
f = &traction;
break;
case field::traction_x:
f = &traction_x;
break;
Expand Down Expand Up @@ -2102,9 +2116,9 @@ dimensionalize(const field::NekFieldEnum & field, double & value)
case field::wall_shear:
// TODO: add dimensionalization
break;
// case field::traction:
// // TODO: add dimensionalization
// break;
case field::traction:
// TODO: add dimensionalization
break;
case field::traction_x:
// TODO: add dimensionalization
break;
Expand Down
6 changes: 3 additions & 3 deletions src/base/NekRSProblemBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,8 @@ NekRSProblemBase::extractOutputs()
field_enum = field::scalar03;
else if (_var_names[i] == "wall_shear")
field_enum = field::wall_shear;
// else if (_var_names[i] == "traction")
// field_enum = field::traction;
else if (_var_names[i] == "traction")
field_enum = field::traction;
else if (_var_names[i] == "traction_x")
field_enum = field::traction_x;
else if (_var_names[i] == "traction_y")
Expand Down Expand Up @@ -1013,7 +1013,7 @@ NekRSProblemBase::addExternalVariables()
}
else if (output == "traction")
{
// _var_names.push_back("traction");
_var_names.push_back("traction");
_var_names.push_back("traction_x");
_var_names.push_back("traction_y");
_var_names.push_back("traction_z");
Expand Down

0 comments on commit 9109e82

Please sign in to comment.