Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
28ab5d51
Commit
28ab5d51
authored
15 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
add structured grid function
parent
cc152e83
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Solver/dgGroupOfElements.cpp
+8
-4
8 additions, 4 deletions
Solver/dgGroupOfElements.cpp
Solver/function.cpp
+91
-3
91 additions, 3 deletions
Solver/function.cpp
with
99 additions
and
7 deletions
Solver/dgGroupOfElements.cpp
+
8
−
4
View file @
28ab5d51
...
@@ -337,8 +337,10 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
...
@@ -337,8 +337,10 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
_groupLeft
(
elGroup
),
_groupRight
(
elGroup
)
_groupLeft
(
elGroup
),
_groupRight
(
elGroup
)
{
{
_boundaryTag
=
boundaryTag
;
_boundaryTag
=
boundaryTag
;
if
(
boundaryTag
==
""
)
if
(
boundaryTag
==
""
){
throw
;
Msg
::
Warning
(
"empty boundary tag, group of boundary faces not created"
);
return
;
}
_fsLeft
=
_groupLeft
.
getElement
(
0
)
->
getFunctionSpace
(
pOrder
);
_fsLeft
=
_groupLeft
.
getElement
(
0
)
->
getFunctionSpace
(
pOrder
);
_closuresLeft
=
_fsLeft
->
vertexClosure
;
_closuresLeft
=
_fsLeft
->
vertexClosure
;
_fsRight
=
NULL
;
_fsRight
=
NULL
;
...
@@ -357,8 +359,10 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
...
@@ -357,8 +359,10 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
_groupLeft
(
elGroup
),
_groupRight
(
elGroup
)
_groupLeft
(
elGroup
),
_groupRight
(
elGroup
)
{
{
_boundaryTag
=
boundaryTag
;
_boundaryTag
=
boundaryTag
;
if
(
boundaryTag
==
""
)
if
(
boundaryTag
==
""
){
throw
;
Msg
::
Warning
(
"empty boundary tag, group of boundary faces not created"
);
return
;
}
_fsLeft
=
_groupLeft
.
getElement
(
0
)
->
getFunctionSpace
(
pOrder
);
_fsLeft
=
_groupLeft
.
getElement
(
0
)
->
getFunctionSpace
(
pOrder
);
_closuresLeft
=
_fsLeft
->
edgeClosure
;
_closuresLeft
=
_fsLeft
->
edgeClosure
;
_fsRight
=
NULL
;
_fsRight
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
Solver/function.cpp
+
91
−
3
View file @
28ab5d51
#include
<sstream>
#include
<fstream>
#include
"function.h"
#include
"function.h"
#include
"SPoint3.h"
#include
"SPoint3.h"
#include
"MElement.h"
#include
"MElement.h"
#include
<sstream>
// dataCache members
// dataCache members
dataCache
::
dataCache
(
dataCacheMap
*
cacheMap
)
:
_valid
(
false
)
{
dataCache
::
dataCache
(
dataCacheMap
*
cacheMap
)
:
_valid
(
false
)
{
...
@@ -37,8 +38,10 @@ function *function::get(std::string functionName, bool acceptNull)
...
@@ -37,8 +38,10 @@ function *function::get(std::string functionName, bool acceptNull)
if
(
it
==
_allFunctions
.
end
())
{
if
(
it
==
_allFunctions
.
end
())
{
if
(
acceptNull
)
if
(
acceptNull
)
return
NULL
;
return
NULL
;
else
else
{
Msg
::
Error
(
"unknown function : '%s'
\n
"
,
functionName
.
c_str
());
throw
;
throw
;
}
}
}
return
it
->
second
;
return
it
->
second
;
}
}
...
@@ -115,6 +118,83 @@ class functionXYZ : public function {
...
@@ -115,6 +118,83 @@ class functionXYZ : public function {
}
}
};
};
class
functionStructuredGridFile
:
public
function
{
public:
class
data
;
std
::
string
_coordFunction
;
int
n
[
3
];
double
d
[
3
],
o
[
3
];
double
get
(
int
i
,
int
j
,
int
k
){
return
v
[(
i
*
n
[
1
]
+
j
)
*
n
[
2
]
+
k
];
}
double
*
v
;
class
data
:
public
dataCacheDouble
{
dataCacheDouble
&
coord
;
functionStructuredGridFile
*
_fun
;
public:
data
(
functionStructuredGridFile
*
fun
,
dataCacheMap
*
m
)
:
dataCacheDouble
(
*
m
,
m
->
getNbEvaluationPoints
(),
1
),
coord
(
m
->
get
(
fun
->
_coordFunction
,
this
))
{
_fun
=
fun
;
}
void
_eval
(){
for
(
int
pt
=
0
;
pt
<
_value
.
size1
();
pt
++
){
double
xi
[
3
];
int
id
[
3
];
for
(
int
i
=
0
;
i
<
3
;
i
++
){
id
[
i
]
=
(
int
)((
coord
(
pt
,
i
)
-
_fun
->
o
[
i
])
/
_fun
->
d
[
i
]);
int
a
=
id
[
i
];
id
[
i
]
=
std
::
max
(
0
,
std
::
min
(
_fun
->
n
[
i
]
-
1
,
id
[
i
]));
xi
[
i
]
=
(
coord
(
pt
,
i
)
-
_fun
->
o
[
i
]
-
id
[
i
]
*
_fun
->
d
[
i
])
/
_fun
->
d
[
i
];
xi
[
i
]
=
std
::
min
(
1.
,
std
::
max
(
0.
,
xi
[
i
]));
}
_value
(
pt
,
0
)
=
_fun
->
get
(
id
[
0
]
,
id
[
1
]
,
id
[
2
]
)
*
(
1
-
xi
[
0
])
*
(
1
-
xi
[
1
])
*
(
1
-
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
,
id
[
1
]
,
id
[
2
]
+
1
)
*
(
1
-
xi
[
0
])
*
(
1
-
xi
[
1
])
*
(
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
,
id
[
1
]
+
1
,
id
[
2
]
)
*
(
1
-
xi
[
0
])
*
(
xi
[
1
])
*
(
1
-
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
,
id
[
1
]
+
1
,
id
[
2
]
+
1
)
*
(
1
-
xi
[
0
])
*
(
xi
[
1
])
*
(
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
+
1
,
id
[
1
]
,
id
[
2
]
)
*
(
xi
[
0
])
*
(
1
-
xi
[
1
])
*
(
1
-
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
+
1
,
id
[
1
]
,
id
[
2
]
+
1
)
*
(
xi
[
0
])
*
(
1
-
xi
[
1
])
*
(
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
+
1
,
id
[
1
]
+
1
,
id
[
2
]
)
*
(
xi
[
0
])
*
(
xi
[
1
])
*
(
1
-
xi
[
2
])
+
_fun
->
get
(
id
[
0
]
+
1
,
id
[
1
]
+
1
,
id
[
2
]
+
1
)
*
(
xi
[
0
])
*
(
xi
[
1
])
*
(
xi
[
2
]);
}
}
};
dataCacheDouble
*
newDataCache
(
dataCacheMap
*
m
)
{
return
new
data
(
this
,
m
);
}
functionStructuredGridFile
(
const
std
::
string
filename
,
const
std
::
string
coordFunction
){
_coordFunction
=
coordFunction
;
std
::
ifstream
input
(
filename
.
c_str
());
if
(
!
input
)
Msg
::
Error
(
"cannot open file : %s"
,
filename
.
c_str
());
if
(
filename
.
substr
(
filename
.
size
()
-
4
,
4
)
!=
".bin"
)
{
input
>>
o
[
0
]
>>
o
[
1
]
>>
o
[
2
]
>>
d
[
0
]
>>
d
[
1
]
>>
d
[
2
]
>>
n
[
0
]
>>
n
[
1
]
>>
n
[
2
];
int
nt
=
n
[
0
]
*
n
[
1
]
*
n
[
2
];
v
=
new
double
[
nt
];
for
(
int
i
=
0
;
i
<
nt
;
i
++
){
input
>>
v
[
i
];
}
}
else
{
input
.
read
((
char
*
)
o
,
3
*
sizeof
(
double
));
input
.
read
((
char
*
)
d
,
3
*
sizeof
(
double
));
input
.
read
((
char
*
)
n
,
3
*
sizeof
(
int
));
int
nt
=
n
[
0
]
*
n
[
1
]
*
n
[
2
];
v
=
new
double
[
nt
];
input
.
read
((
char
*
)
v
,
nt
*
sizeof
(
double
));
}
static
int
c
=
0
;
std
::
ostringstream
oss
;
oss
<<
"FunctionStructured"
<<
c
++
;
_name
=
oss
.
str
();
function
::
add
(
_name
,
this
);
}
~
functionStructuredGridFile
(){
delete
[]
v
;
}
};
// constant values copied over each line
// constant values copied over each line
class
functionConstant
::
data
:
public
dataCacheDouble
{
class
functionConstant
::
data
:
public
dataCacheDouble
{
...
@@ -180,7 +260,6 @@ public:
...
@@ -180,7 +260,6 @@ public:
};
};
*/
*/
#include
"Bindings.h"
#include
"Bindings.h"
void
function
::
registerDefaultFunctions
()
void
function
::
registerDefaultFunctions
()
...
@@ -193,11 +272,20 @@ void function::registerBindings(binding *b){
...
@@ -193,11 +272,20 @@ void function::registerBindings(binding *b){
methodBinding
*
mb
;
methodBinding
*
mb
;
mb
=
cb
->
addMethod
(
"getName"
,
&
function
::
getName
);
mb
=
cb
->
addMethod
(
"getName"
,
&
function
::
getName
);
mb
->
setDescription
(
"Return the string which identifies this function."
);
mb
->
setDescription
(
"Return the string which identifies this function."
);
cb
=
b
->
addClass
<
functionConstant
>
(
"functionConstant"
);
cb
=
b
->
addClass
<
functionConstant
>
(
"functionConstant"
);
cb
->
setDescription
(
"A constant (scalar or vector) function"
);
cb
->
setDescription
(
"A constant (scalar or vector) function"
);
mb
=
cb
->
setConstructor
<
functionConstant
,
fullMatrix
<
double
>*>
();
mb
=
cb
->
setConstructor
<
functionConstant
,
fullMatrix
<
double
>*>
();
mb
->
setArgNames
(
"v"
,
NULL
);
mb
->
setArgNames
(
"v"
,
NULL
);
mb
->
setDescription
(
"A new constant function wich values 'v' everywhere. v can be a row-vector."
);
mb
->
setDescription
(
"A new constant function wich values 'v' everywhere. v can be a row-vector."
);
cb
->
setParentClass
<
function
>
();
cb
->
setParentClass
<
function
>
();
cb
=
b
->
addClass
<
functionStructuredGridFile
>
(
"functionStructuredGridFile"
);
cb
->
setParentClass
<
function
>
();
cb
->
setDescription
(
"A function to interpolate through data given on a structured grid"
);
mb
=
cb
->
setConstructor
<
functionStructuredGridFile
,
std
::
string
,
std
::
string
>
();
mb
->
setArgNames
(
"fileName"
,
"coordinateFunction"
,
NULL
);
mb
->
setDescription
(
"Tri-linearly interpolate through data in file 'fileName' at coordinate given by 'coordinateFunction'.
\n
The file format is :
\n
x0 y0 z0
\n
dx dy dz
\n
nx ny nz
\n
v(0,0,0) v(0,0,1) v(0 0 2) ..."
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment