Skip to content

Commit 72da3eb

Browse files
author
Teseo Schneider
committed
added new problem
1 parent 3099454 commit 72da3eb

3 files changed

Lines changed: 115 additions & 105 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# polyfem-python
2-
[![Build Status](https://travis-ci.com/polyfem/polyfem-python.svg?branch=master)](https://travis-ci.com/polyfem/polyfem-python)
3-
[![Build status](https://ci.appveyor.com/api/projects/status/lqfxi2pbkhpatxls?svg=true)](https://ci.appveyor.com/project/teseoch/polyfem-python)
4-
2+
![Build](https://github.com/polyfem/polyfem-python/workflows/Build/badge.svg)
53

64

75
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/polyfempy/badges/latest_release_date.svg)](https://anaconda.org/conda-forge/polyfempy)

polyfempy/Problems.py

Lines changed: 113 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -3,157 +3,168 @@
33
#################################################
44
############Scalar###############################
55
class Franke:
6-
"""Franke problem with exact solution https://polyfem.github.io/documentation/#franke"""
6+
"""Franke problem with exact solution https://polyfem.github.io/documentation/#franke"""
77

8-
def name(self):
9-
return "Franke"
8+
def name(self):
9+
return "Franke"
1010

11-
def params(self):
12-
return {}
11+
def params(self):
12+
return {}
1313

1414

1515
class GenericScalar:
16-
"""Generic scalar problem https://polyfem.github.io/documentation/#genericscalar"""
16+
"""Generic scalar problem https://polyfem.github.io/documentation/#genericscalar"""
1717

18-
def __init__(self):
19-
self.rhs = 0
20-
self.exact = None
21-
self.dirichlet_boundary = []
22-
self.neumann_boundary = []
18+
def __init__(self):
19+
self.rhs = 0
20+
self.exact = None
21+
self.dirichlet_boundary = []
22+
self.neumann_boundary = []
2323

24-
def add_dirichlet_value(self, id, value):
25-
"""add the Dirichlet value value for the sideset id"""
24+
def add_dirichlet_value(self, id, value):
25+
"""add the Dirichlet value value for the sideset id"""
2626

27-
tmp = {}
28-
tmp["id"] = id
29-
tmp["value"] = value
30-
self.dirichlet_boundary.append(tmp)
27+
tmp = {}
28+
tmp["id"] = id
29+
tmp["value"] = value
30+
self.dirichlet_boundary.append(tmp)
3131

32-
def add_neumann_value(self, id, value):
33-
"""add the Neumann value value for the sideset id"""
32+
def add_neumann_value(self, id, value):
33+
"""add the Neumann value value for the sideset id"""
3434

35-
tmp = {}
36-
tmp["id"] = id
37-
tmp["value"] = value
38-
self.neumann_boundary.append(tmp)
35+
tmp = {}
36+
tmp["id"] = id
37+
tmp["value"] = value
38+
self.neumann_boundary.append(tmp)
3939

40-
def name(self):
41-
return "GenericScalar"
40+
def name(self):
41+
return "GenericScalar"
4242

43-
def params(self):
44-
return self.__dict__
43+
def params(self):
44+
return self.__dict__
4545

4646

4747
#################################################
4848
############Elasticity###########################
4949
class Gravity:
50-
"""time dependent gravity problem https://polyfem.github.io/documentation/#gravity"""
50+
"""time dependent gravity problem https://polyfem.github.io/documentation/#gravity"""
5151

52-
def __init__(self, force=0.1):
53-
self.force = force
52+
def __init__(self, force=0.1):
53+
self.force = force
5454

55-
def name(self):
56-
return "Gravity"
55+
def name(self):
56+
return "Gravity"
5757

58-
def params(self):
59-
return self.__dict__
58+
def params(self):
59+
return self.__dict__
6060

6161

6262
class Torsion:
63-
"""3D torsion problem, specify which sideset to fix (fixed_boundary) and which one turns turning_boundary https://polyfem.github.io/documentation/#torsionelastic"""
63+
"""3D torsion problem, specify which sideset to fix (fixed_boundary) and which one turns turning_boundary https://polyfem.github.io/documentation/#torsionelastic"""
6464

65-
def __init__(self, axis_coordiante=None, axis_coordinate=2, n_turns=0.5, fixed_boundary=5, turning_boundary=6):
66-
if axis_coordiante:
67-
self.axis_coordiante = axis_coordiante
68-
else:
69-
self.axis_coordiante = axis_coordinate
70-
self.n_turns = n_turns
71-
self.fixed_boundary = fixed_boundary
72-
self.turning_boundary = turning_boundary
65+
def __init__(self, axis_coordiante=None, axis_coordinate=2, n_turns=0.5, fixed_boundary=5, turning_boundary=6):
66+
if axis_coordiante:
67+
self.axis_coordiante = axis_coordiante
68+
else:
69+
self.axis_coordiante = axis_coordinate
70+
self.n_turns = n_turns
71+
self.fixed_boundary = fixed_boundary
72+
self.turning_boundary = turning_boundary
7373

74+
def name(self):
75+
return "TorsionElastic"
7476

75-
def name(self):
76-
return "TorsionElastic"
77-
78-
79-
def params(self):
80-
return self.__dict__
77+
def params(self):
78+
return self.__dict__
8179

8280

8381
class GenericTensor:
84-
"""Generic tensor problem https://polyfem.github.io/documentation/#generictensor"""
82+
"""Generic tensor problem https://polyfem.github.io/documentation/#generictensor"""
8583

86-
def __init__(self):
87-
self.rhs = [0, 0, 0]
88-
self.exact = None
89-
self.dirichlet_boundary = []
90-
self.neumann_boundary = []
84+
def __init__(self):
85+
self.rhs = [0, 0, 0]
86+
self.exact = None
87+
self.dirichlet_boundary = []
88+
self.neumann_boundary = []
9189

92-
def set_velocity(self, id, value, is_dim_fixed=None):
93-
"""set the velocity value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
94-
self.add_dirichlet_value(id, value, is_dim_fixed)
90+
def set_velocity(self, id, value, is_dim_fixed=None):
91+
"""set the velocity value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
92+
self.add_dirichlet_value(id, value, is_dim_fixed)
9593

96-
def set_displacement(self, id, value, is_dim_fixed=None):
97-
"""set the displacement value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
98-
self.add_dirichlet_value(id, value, is_dim_fixed)
94+
def set_displacement(self, id, value, is_dim_fixed=None):
95+
"""set the displacement value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
96+
self.add_dirichlet_value(id, value, is_dim_fixed)
9997

100-
def set_force(self, id, value):
101-
"""set the force value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
102-
self.add_neumann_value(id, value)
98+
def set_force(self, id, value):
99+
"""set the force value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
100+
self.add_neumann_value(id, value)
103101

102+
def add_dirichlet_value(self, id, value, is_dirichlet_dim=None):
103+
"""add the Dirichlet value value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem. is_dirichlet_dim is a vector of boolean specifying which dimentions are fixed."""
104+
assert(len(value) == 3 or len(value) == 2)
105+
tmp = {}
106+
tmp["id"] = id
107+
tmp["value"] = value
108+
if is_dirichlet_dim is not None:
109+
assert(len(is_dirichlet_dim) == 3 or len(is_dirichlet_dim) == 2)
110+
tmp["dimension"] = is_dirichlet_dim
104111

105-
def add_dirichlet_value(self, id, value, is_dirichlet_dim=None):
106-
"""add the Dirichlet value value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem. is_dirichlet_dim is a vector of boolean specifying which dimentions are fixed."""
107-
assert(len(value) == 3 or len(value) == 2)
108-
tmp = {}
109-
tmp["id"] = id
110-
tmp["value"] = value
111-
if is_dirichlet_dim is not None:
112-
assert(len(is_dirichlet_dim) == 3 or len(is_dirichlet_dim) == 2)
113-
tmp["dimension"] = is_dirichlet_dim
112+
self.dirichlet_boundary.append(tmp)
114113

115-
self.dirichlet_boundary.append(tmp)
114+
def add_neumann_value(self, id, value):
115+
"""add the Neumann value value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
116116

117-
def add_neumann_value(self, id, value):
118-
"""add the Neumann value value for the sideset id. Note the value must be a vector in 2D or 3D depending on the problem"""
117+
tmp = {}
118+
tmp["id"] = id
119+
tmp["value"] = value
120+
self.neumann_boundary.append(tmp)
119121

120-
tmp = {}
121-
tmp["id"] = id
122-
tmp["value"] = value
123-
self.neumann_boundary.append(tmp)
122+
def name(self):
123+
return "GenericTensor"
124124

125-
def name(self):
126-
return "GenericTensor"
127-
128-
def params(self):
129-
return self.__dict__
125+
def params(self):
126+
return self.__dict__
130127

131128

132129
#################################################
133130
############Stokes###############################
134131
class Flow:
135-
"""Inflow/outflow problem for fluids. You can specify the sideset for the moving fluxes, the axial direction of the flow, and the list of obstacle sidesets. https://polyfem.github.io/documentation/#flow"""
132+
"""Inflow/outflow problem for fluids. You can specify the sideset for the moving fluxes, the axial direction of the flow, and the list of obstacle sidesets. https://polyfem.github.io/documentation/#flow"""
136133

137-
def __init__(self, inflow=1, outflow=3, inflow_amout=0.25, outflow_amout=0.25, direction=0, obstacle=[7]):
138-
self.inflow = inflow
139-
self.outflow = outflow
140-
self.inflow_amout = inflow_amout
141-
self.outflow_amout = outflow_amout
142-
self.direction = direction
143-
self.obstacle = obstacle
134+
def __init__(self, inflow=1, outflow=3, inflow_amout=0.25, outflow_amout=0.25, direction=0, obstacle=[7]):
135+
self.inflow = inflow
136+
self.outflow = outflow
137+
self.inflow_amout = inflow_amout
138+
self.outflow_amout = outflow_amout
139+
self.direction = direction
140+
self.obstacle = obstacle
144141

145-
def name(self):
146-
return "Flow"
142+
def name(self):
143+
return "Flow"
147144

148-
def params(self):
149-
return self.__dict__
145+
def params(self):
146+
return self.__dict__
150147

151148

152149
class DrivenCavity:
153-
"""Classical driven cavity problem in fluid simulation"""
150+
"""Classical driven cavity problem in fluid simulation"""
151+
152+
def name(self):
153+
return "DrivenCavity"
154+
155+
def params(self):
156+
return {}
157+
158+
159+
class FlowWithObstacle:
160+
"""FLuid Obstacle problem"""
161+
162+
def __init__(self, U=1.5, time_dependent=True):
163+
self.U = U
164+
self.time_dependent = time_dependent
154165

155-
def name(self):
156-
return "DrivenCavity"
166+
def name(self):
167+
return "FlowWithObstacle"
157168

158-
def params(self):
159-
return {}
169+
def params(self):
170+
return self.__dict__

polyfempy/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
from .Problems import GenericTensor
1515
from .Problems import Flow
1616
from .Problems import DrivenCavity
17+
from .Problems import FlowWithObstacle

0 commit comments

Comments
 (0)