Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hog
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
hyteg
hog
Commits
7c0a322a
Commit
7c0a322a
authored
1 month ago
by
Ponsuganth Ilangovan Ponkumar Ilango
Browse files
Options
Downloads
Patches
Plain Diff
Add weak form for penalising rigid body mode - angular momentum
parent
b88dccdb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
generate_all_operators.py
+3
-0
3 additions, 0 deletions
generate_all_operators.py
hog/forms.py
+83
-0
83 additions, 0 deletions
hog/forms.py
hog/recipes/integrands/volume/rigid_mode_angular.py
+49
-0
49 additions, 0 deletions
hog/recipes/integrands/volume/rigid_mode_angular.py
with
135 additions
and
0 deletions
generate_all_operators.py
+
3
−
0
View file @
7c0a322a
...
@@ -47,6 +47,7 @@ from hog.element_geometry import (
...
@@ -47,6 +47,7 @@ from hog.element_geometry import (
from
hog.exception
import
HOGException
from
hog.exception
import
HOGException
from
hog.forms
import
(
from
hog.forms
import
(
diffusion
,
diffusion
,
rigid_body_mode_angular
,
divergence
,
divergence
,
gradient
,
gradient
,
div_k_grad
,
div_k_grad
,
...
@@ -665,6 +666,8 @@ def all_operators(
...
@@ -665,6 +666,8 @@ def all_operators(
ops
.
append
(
OperatorInfo
(
"
P2PlusBubble
"
,
"
Diffusion
"
,
TrialSpace
(
P2PlusBubble
),
TestSpace
(
P2PlusBubble
),
form
=
diffusion
,
ops
.
append
(
OperatorInfo
(
"
P2PlusBubble
"
,
"
Diffusion
"
,
TrialSpace
(
P2PlusBubble
),
TestSpace
(
P2PlusBubble
),
form
=
diffusion
,
type_descriptor
=
type_descriptor
,
geometries
=
two_d
,
opts
=
opts
,
blending
=
blending
))
type_descriptor
=
type_descriptor
,
geometries
=
two_d
,
opts
=
opts
,
blending
=
blending
))
ops
.
append
(
OperatorInfo
(
"
P2Vector
"
,
"
RigidModeAngular
"
,
TrialSpace
(
P2Vector
),
TestSpace
(
P2Vector
),
form
=
rigid_body_mode_angular
,
type_descriptor
=
type_descriptor
,
geometries
=
list
(
geometries
),
opts
=
opts
,
blending
=
blending
))
# fmt: on
# fmt: on
p2vec_epsilon
=
partial
(
p2vec_epsilon
=
partial
(
...
...
This diff is collapsed.
Click to expand it.
hog/forms.py
+
83
−
0
View file @
7c0a322a
...
@@ -545,6 +545,49 @@ def linear_form(
...
@@ -545,6 +545,49 @@ def linear_form(
return
mat
return
mat
def
rigid_body_mode_angular
(
trial
:
TrialSpace
,
test
:
TestSpace
,
geometry
:
ElementGeometry
,
symbolizer
:
Symbolizer
,
blending
:
GeometryMap
,
rotation_wrapper
:
bool
=
False
,
)
->
Form
:
docstring
=
f
"""
Rigid Body Mode -- Angular Momentum.
Geometry map:
{
blending
}
Weak formulation
u: trial function (vectorial space:
{
trial
}
)
v: test function (vectorial space:
{
test
}
)
∫ ( ud · u ) ( ud · v )
ud encompasses the unit vectors pointing in the direction
of the three rigid body modes
"""
from
hog.recipes.integrands.volume.rigid_mode_angular
import
integrand
from
hog.recipes.integrands.volume.rotation
import
RotationType
if
isinstance
(
blending
,
IdentityMap
):
raise
HOGException
(
"
Rigid body mode only applicable for Annulus and IcosahedralShell map
"
)
return
process_integrand
(
integrand
,
trial
,
test
,
geometry
,
symbolizer
,
blending
=
blending
,
is_symmetric
=
True
,
docstring
=
docstring
,
rot_type
=
RotationType
.
POST_MULTIPLY
if
rotation_wrapper
else
RotationType
.
NO_ROTATION
,
)
def
divergence
(
def
divergence
(
trial
:
TrialSpace
,
trial
:
TrialSpace
,
...
@@ -587,6 +630,46 @@ Weak formulation
...
@@ -587,6 +630,46 @@ Weak formulation
else
RotationType
.
NO_ROTATION
,
else
RotationType
.
NO_ROTATION
,
)
)
def
divergence
(
trial
:
TrialSpace
,
test
:
TestSpace
,
geometry
:
ElementGeometry
,
symbolizer
:
Symbolizer
,
blending
:
GeometryMap
=
IdentityMap
(),
component_index
:
int
=
0
,
rotation_wrapper
:
bool
=
False
,
)
->
Form
:
docstring
=
f
"""
Divergence.
Component:
{
component_index
}
Geometry map:
{
blending
}
Weak formulation
u: trial function (vectorial space:
{
trial
}
)
v: test function (scalar space:
{
test
}
)
∫ - ( ∇ · u ) v
"""
from
hog.recipes.integrands.volume.divergence
import
integrand
from
hog.recipes.integrands.volume.rotation
import
RotationType
return
process_integrand
(
integrand
,
trial
,
test
,
geometry
,
symbolizer
,
blending
=
blending
,
component_index
=
component_index
,
is_symmetric
=
False
,
docstring
=
docstring
,
rot_type
=
RotationType
.
POST_MULTIPLY
if
rotation_wrapper
else
RotationType
.
NO_ROTATION
,
)
def
gradient
(
def
gradient
(
trial
:
TrialSpace
,
trial
:
TrialSpace
,
...
...
This diff is collapsed.
Click to expand it.
hog/recipes/integrands/volume/rigid_mode_angular.py
0 → 100644
+
49
−
0
View file @
7c0a322a
# HyTeG Operator Generator
# Copyright (C) 2024 HyTeG Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from
hog.recipes.common
import
*
def
integrand
(
*
,
jac_a_abs_det
,
jac_b_abs_det
,
u
,
v
,
x
,
scalars
,
tabulate
,
volume_geometry
,
**
_
,
):
c_rot_penalty
=
scalars
(
"
c_rot_penalty
"
)
if
volume_geometry
.
dimensions
==
2
:
rigid_z
=
sp
.
Matrix
([[
-
x
[
1
,
0
]],
[
x
[
0
,
0
]]])
rigid_body_model_val
=
dot
(
rigid_z
,
u
)
*
dot
(
rigid_z
,
v
)
elif
volume_geometry
.
dimensions
==
3
:
rigid_z
=
sp
.
Matrix
([[
-
x
[
1
,
0
]],
[
x
[
0
,
0
]],
[
0
]])
rigid_z
=
rigid_z
/
rigid_z
.
norm
()
rigid_y
=
sp
.
Matrix
([[
0
],
[
-
x
[
2
,
0
]],
[
x
[
1
,
0
]]])
rigid_y
=
rigid_y
/
rigid_y
.
norm
()
rigid_x
=
sp
.
Matrix
([[
x
[
2
,
0
]],
[
0
],
[
-
x
[
0
,
0
]]])
rigid_x
=
rigid_x
/
rigid_x
.
norm
()
rigid_body_model_val
=
dot
(
rigid_z
,
u
)
*
dot
(
rigid_z
,
v
)
+
dot
(
rigid_y
,
u
)
*
dot
(
rigid_y
,
v
)
+
dot
(
rigid_x
,
u
)
*
dot
(
rigid_x
,
v
)
return
(
c_rot_penalty
*
rigid_body_model_val
)
*
tabulate
(
jac_a_abs_det
)
*
jac_b_abs_det
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