Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mavt-cse
Cubism
Commits
ecf1f314
Commit
ecf1f314
authored
Apr 09, 2019
by
novatig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix sinusoidal mesh grid kernel
parent
39badfaa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
include/Cubism/MeshKernels.h
include/Cubism/MeshKernels.h
+20
-21
No files found.
include/Cubism/MeshKernels.h
View file @
ecf1f314
...
...
@@ -13,7 +13,7 @@
#include <limits>
#include <vector>
#include <string>
#include <iostream>
//
#include <iostream>
#include <cstdlib>
#include <random> // C++11
...
...
@@ -536,42 +536,41 @@ public:
const
unsigned
int
ghostS
=
0
,
const
unsigned
int
ghostE
=
0
,
double
*
const
ghost_spacing
=
NULL
)
const
{
const
unsigned
int
total_cells
=
ncells
+
ghostE
+
ghostS
;
double
*
const
buf
=
new
double
[
total_cells
];
double
*
const
DH
=
new
double
[
total_cells
];
double
*
const
Yface
=
new
double
[
ncells
+
1
];
double
sumDH
=
0
;
// interior
const
unsigned
int
nhalf
=
ncells
/
2
+
ncells
%
2
;
const
double
h
=
2.0
/
ncells
;
double
ducky
=
0.0
;
for
(
unsigned
int
i
=
0
;
i
<
nhalf
;
++
i
)
for
(
unsigned
int
i
=
0
;
i
<=
ncells
;
++
i
)
{
const
double
x
=
h
*
(
i
+
0.5
)
-
1.0
;
const
double
dh
=
std
::
sin
(
0.5
*
eta
*
x
*
M_PI
)
/
std
::
sin
(
0.5
*
eta
*
M_PI
)
+
1.0
;
buf
[
i
+
ghostS
]
=
dh
;
buf
[
ncells
-
1
-
i
+
ghostS
]
=
dh
;
ducky
+=
2
*
dh
;
const
double
x
=
2
*
i
/
(
double
)
ncells
-
1.0
;
// maps i to -1 : 1
// both x and y are mapped to -1 : 1, but one is refined @ edges
Yface
[
i
]
=
std
::
sin
(
.5
*
eta
*
x
*
M_PI
)
/
std
::
sin
(
.5
*
eta
*
M_PI
);
// sum grid spacing together in order to enforce sumDH == extent
if
(
i
==
0
)
continue
;
// skip first face
assert
(
Yface
[
i
]
-
Yface
[
i
-
1
]
>
0
&&
"Requires posdef grid spacing"
);
DH
[
i
-
1
+
ghostS
]
=
Yface
[
i
]
-
Yface
[
i
-
1
];
sumDH
+=
Yface
[
i
]
-
Yface
[
i
-
1
];
}
if
(
ncells
%
2
==
1
)
ducky
-=
buf
[
ghostS
+
nhalf
-
1
];
const
double
scale
=
(
xE
-
xS
)
/
ducky
;
const
double
scale
=
(
xE
-
xS
)
/
sumDH
;
for
(
unsigned
int
i
=
0
;
i
<
ncells
;
++
i
)
buf
[
i
+
ghostS
]
*=
scale
;
DH
[
i
+
ghostS
]
*=
scale
;
for
(
unsigned
int
i
=
0
;
i
<
ncells
;
++
i
)
ary
[
i
]
=
buf
[
i
+
ghostS
];
ary
[
i
]
=
DH
[
i
+
ghostS
];
assert
(
ghostS
==
ghostE
);
if
(
ghost_spacing
)
{
for
(
unsigned
int
i
=
0
;
i
<
ghostS
;
++
i
)
ghost_spacing
[
ghostS
-
1
-
i
]
=
buf
[
ghostS
+
i
];
ghost_spacing
[
ghostS
-
1
-
i
]
=
DH
[
ghostS
+
i
];
for
(
unsigned
int
i
=
0
;
i
<
ghostE
;
++
i
)
ghost_spacing
[
i
+
ghostS
]
=
buf
[
ncells
-
1
+
ghostS
-
i
];
ghost_spacing
[
i
+
ghostS
]
=
DH
[
ncells
-
1
+
ghostS
-
i
];
}
// clean up
delete
[]
buf
;
delete
[]
DH
;
delete
[]
Yface
;
}
virtual
std
::
string
name
()
const
{
return
std
::
string
(
"SinusoidalDensity"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment