Skip to content

Commit

Permalink
adds rate of strain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anshchaube committed May 10, 2024
1 parent 39f2c5e commit 9c0ddd9
Show file tree
Hide file tree
Showing 20 changed files with 538 additions and 35 deletions.
18 changes: 2 additions & 16 deletions test/tests/traction/rate_of_strain_x/gold/nek_out.csv
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
time,ros_s11_error,ros_s12_error,ros_s13_error,ros_s22_error,ros_s23_error,ros_s33_error
0,0,0,0,0,0,0
0.001,1.7788370881837e-05,1.124544739804e-05,1.0927354906885e-05,8.3316764831973e-07,1.5573008395803e-06,3.9717151671545e-06
0.002,1.7990379674145e-05,8.2741876163407e-06,8.1777237618186e-06,1.047183538185e-06,2.0566640617152e-06,5.1979989064878e-06
0.003,1.7008901193357e-05,7.5061590640703e-06,7.5452153212063e-06,1.1326467233011e-06,2.1980592109667e-06,5.5510095729753e-06
0.004,1.6425953620721e-05,7.1688791776269e-06,7.2331433603273e-06,1.1606622877769e-06,2.2382257750015e-06,5.6574800345524e-06
0.005,1.6076720717661e-05,6.9745764206209e-06,7.034651745643e-06,1.1707502807078e-06,2.2536356019037e-06,5.6979142393666e-06
0.006,1.5807137755629e-05,6.8258527379262e-06,6.8962251578449e-06,1.1756448718779e-06,2.2565148001099e-06,5.7052020469227e-06
0.007,1.5607290282128e-05,6.7127018981517e-06,6.8000996758146e-06,1.1769964397184e-06,2.2546879740816e-06,5.7005011052793e-06
0.008,1.546312876904e-05,6.6112175358788e-06,6.7138133909542e-06,1.1767041180867e-06,2.2534734678031e-06,5.6970040018043e-06
0.009,1.5345129200374e-05,6.5328167894391e-06,6.6483797808234e-06,1.1759788257306e-06,2.252321482361e-06,5.6936682694598e-06
0.01,1.5257291225058e-05,6.4598986383759e-06,6.5876244862067e-06,1.1753873935403e-06,2.2517748707824e-06,5.6916636353147e-06
0.011,1.5194929435001e-05,6.4016510714056e-06,6.5391170391646e-06,1.1748947751973e-06,2.2516472418421e-06,5.690696395874e-06
0.012,1.5128113067298e-05,6.3452834609234e-06,6.4914760357088e-06,1.1740304296681e-06,2.2510350063298e-06,5.6884558849407e-06
0.013,1.508479257171e-05,6.3002798816218e-06,6.4537927209699e-06,1.1734173739047e-06,2.2507719881076e-06,5.6871639869319e-06
0.014,1.5037955696726e-05,6.2568769461611e-06,6.4171517345744e-06,1.1725739578847e-06,2.2500012615156e-06,5.6845810035601e-06
time,ros_s11_error,ros_s11_vavg,ros_s12_error,ros_s12_vavg,ros_s13_error,ros_s13_vavg,ros_s22_error,ros_s22_vavg,ros_s23_error,ros_s23_vavg,ros_s33_error,ros_s33_vavg
0.02,8.02713341283e-08,-2.411694334603e-13,4.9590347608804e-07,1.1555908093375e-08,4.9504991070149e-07,1.4005566837309e-08,4.9981353650412e-08,7.6191854080209e-16,2.5508226516982e-08,-7.1428700524922e-16,1.0745445634261e-08,-1.2891062404159e-16
35 changes: 29 additions & 6 deletions test/tests/traction/rate_of_strain_x/nek.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
type = NekRSStandaloneProblem
output = "ros_tensor"
casename = 'pipe'
# n_usrwrk_slots = 6
[]

[Functions]
Expand All @@ -33,13 +32,13 @@
type = ParsedFunction
expression = '-y*u0/R/R'
symbol_names = 'R u0'
symbol_values = '0.5 2.0'
symbol_values = '0.01 2.0'
[]
[s_13_exact]
type = ParsedFunction
expression = '-z*u0/R/R'
symbol_names = 'R u0'
symbol_values = '0.5 2.0'
symbol_values = '0.01 2.0'
[]
[]

Expand All @@ -52,7 +51,7 @@

[Quadrature]
type = GAUSS_LOBATTO
order = SEVENTH
order = FIFTH
[]
[]

Expand Down Expand Up @@ -87,10 +86,34 @@
variable = ros_s13
function = s_13_exact
[]
[ros_s11_vavg]
type = NekVolumeAverage
field = ros_s11
[]
[ros_s22_vavg]
type = NekVolumeAverage
field = ros_s22
[]
[ros_s33_vavg]
type = NekVolumeAverage
field = ros_s33
[]
[ros_s12_vavg]
type = NekVolumeAverage
field = ros_s12
[]
[ros_s13_vavg]
type = NekVolumeAverage
field = ros_s13
[]
[ros_s23_vavg]
type = NekVolumeAverage
field = ros_s23
[]
[]

[Outputs]
exodus = true
exodus = false
csv = true
# execute_on = 'final'
execute_on = 'final'
[]
16 changes: 6 additions & 10 deletions test/tests/traction/rate_of_strain_x/pipe.par
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
[GENERAL]
startFrom = "restart.fld"
polynomialOrder = 7
# stopAt = endTime #numSteps
# endTime = 600
numSteps = 100
dt = 1e-3
# dt = targetCFL=0.45 + max=1e-1 + initial=1e-3
polynomialOrder = 5
numSteps = 200
dt = 1e-4
timeStepper = tombo2
constFlowRate = meanVelocity=1.0 + direction=X
writeInterval = 10
writeInterval = 201

[MESH]
file = "turbPipe.re2"

[PRESSURE]
residualTol = 1e-6
residualTol = 1e-8

[VELOCITY]
density = 1.0
viscosity = -100.0
boundaryTypeMap = wall
residualTol = 1e-8
residualTol = 1e-10

[TEMPERATURE]
solver = none
2 changes: 1 addition & 1 deletion test/tests/traction/rate_of_strain_x/pipe.udf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void UDF_Setup(nrs_t *nrs)
mesh_t* mesh = nrs->cds->mesh[0];
int num_quadrature_points = mesh->Np * mesh->Nelements;

float Rsq = 0.5*0.5;
float Rsq = 1.e-2*1.e-2;
float u0 = 2.0;

for (int n = 0; n < num_quadrature_points; n++) {
Expand Down
8 changes: 7 additions & 1 deletion test/tests/traction/rate_of_strain_x/pipe.usr
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ c-----------------------------------------------------------------------
include 'TOTAL'

integer iel, ifc, i, ntot
real theta, xx, zz
real theta, xx, zz, fac

do iel=1,nelt
do ifc=1,2*ndim
Expand All @@ -35,6 +35,12 @@ c-----------------------------------------------------------------------
zm1(i,1,1,1) = xx*sin(theta) + zz*cos(theta)
enddo

fac = 2.0e-2

call cmult(xm1,fac,ntot)
call cmult(ym1,fac,ntot)
call cmult(zm1,fac,ntot)

return
end
c-----------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion test/tests/traction/rate_of_strain_x/tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
type = CSVDiff
input = nek.i
csvdiff = nek_out.csv
min_parallel = 4
min_parallel = 64
requirement = "Cardinal shall be able to calculate the rate-of-strain tensor components"
"to an acceptable tolerance for a pipe with laminar flow along the x-axis."
required_objects = 'NekRSStandaloneProblem'
max_time = 500
[]
[]
2 changes: 2 additions & 0 deletions test/tests/traction/rate_of_strain_y/gold/nek_out.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
time,ros_s11_error,ros_s11_vavg,ros_s12_error,ros_s12_vavg,ros_s13_error,ros_s13_vavg,ros_s22_error,ros_s22_vavg,ros_s23_error,ros_s23_vavg,ros_s33_error,ros_s33_vavg
0.02,1.0745442549269e-08,-7.0979707164594e-17,4.950498811525e-07,1.4008810172823e-08,2.5508219152504e-08,1.3163657935572e-15,8.0271351983745e-08,2.1873383903722e-12,4.9590341268666e-07,1.1555260289053e-08,4.9981345348697e-08,3.9668723898227e-15
119 changes: 119 additions & 0 deletions test/tests/traction/rate_of_strain_y/nek.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
[Mesh]
type = NekRSMesh
order = SECOND
volume = true
parallel_type = replicated
[]

[Problem]
type = NekRSStandaloneProblem
output = "ros_tensor"
casename = 'pipe'
[]

[Functions]
[s_11_exact]
type = ParsedFunction
expression = 0.0
[]
[s_22_exact]
type = ParsedFunction
expression = 0.0
[]
[s_33_exact]
type = ParsedFunction
expression = 0.0
[]
[s_13_exact]
type = ParsedFunction
expression = 0.0
[]
[s_12_exact]
type = ParsedFunction
expression = '-x*u0/R/R'
symbol_names = 'R u0'
symbol_values = '0.01 2.0'
[]
[s_23_exact]
type = ParsedFunction
expression = '-z*u0/R/R'
symbol_names = 'R u0'
symbol_values = '0.01 2.0'
[]
[]

[Executioner]
type = Transient

[TimeStepper]
type = NekTimeStepper
[]

[Quadrature]
type = GAUSS_LOBATTO
order = FIFTH
[]
[]

[Postprocessors]
[ros_s11_error]
type = ElementL2Error
variable = ros_s11
function = s_11_exact
[]
[ros_s22_error]
type = ElementL2Error
variable = ros_s22
function = s_22_exact
[]
[ros_s33_error]
type = ElementL2Error
variable = ros_s33
function = s_33_exact
[]
[ros_s12_error]
type = ElementL2Error
variable = ros_s12
function = s_12_exact
[]
[ros_s23_error]
type = ElementL2Error
variable = ros_s23
function = s_23_exact
[]
[ros_s13_error]
type = ElementL2Error
variable = ros_s13
function = s_13_exact
[]
[ros_s11_vavg]
type = NekVolumeAverage
field = ros_s11
[]
[ros_s22_vavg]
type = NekVolumeAverage
field = ros_s22
[]
[ros_s33_vavg]
type = NekVolumeAverage
field = ros_s33
[]
[ros_s12_vavg]
type = NekVolumeAverage
field = ros_s12
[]
[ros_s13_vavg]
type = NekVolumeAverage
field = ros_s13
[]
[ros_s23_vavg]
type = NekVolumeAverage
field = ros_s23
[]
[]

[Outputs]
exodus = false
csv = true
execute_on = 'final'
[]
22 changes: 22 additions & 0 deletions test/tests/traction/rate_of_strain_y/pipe.par
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[GENERAL]
polynomialOrder = 5
numSteps = 200
dt = 1e-4
timeStepper = tombo2
constFlowRate = meanVelocity=1.0 + direction=Y
writeInterval = 201

[MESH]
file = "turbPipe.re2"

[PRESSURE]
residualTol = 1e-8

[VELOCITY]
density = 1.0
viscosity = -100.0
boundaryTypeMap = wall
residualTol = 1e-10

[TEMPERATURE]
solver = none
41 changes: 41 additions & 0 deletions test/tests/traction/rate_of_strain_y/pipe.udf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// nekRS User Defined File
//
#include <math.h>
#include "udf.hpp"

#ifdef __okl__

#endif

/* UDF Functions */

void UDF_LoadKernels(occa::properties& kernelInfo)
{
}


void UDF_Setup(nrs_t *nrs)
{
mesh_t* mesh = nrs->cds->mesh[0];
int num_quadrature_points = mesh->Np * mesh->Nelements;

float Rsq = 1.e-2*1.e-2;
float u0 = 2.0;

for (int n = 0; n < num_quadrature_points; n++) {
float xx = mesh->x[n];
float zz = mesh->z[n];

float rr = xx*xx + zz*zz;
nrs->U[n + 0 * nrs->fieldOffset] = 0.0;
nrs->U[n + 1 * nrs->fieldOffset] = u0*(1.0-(rr/Rsq));
nrs->U[n + 2 * nrs->fieldOffset] = 0.0;

nrs->cds->S[n + 0 * nrs->cds->fieldOffset[0]] = 0.0;
}
}

void UDF_ExecuteStep(nrs_t *nrs, dfloat time, int tstep)
{
}
Loading

0 comments on commit 9c0ddd9

Please sign in to comment.