Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.2 version update #1389

Merged
merged 136 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
4c0cd0a
modify test files
brighthe Nov 14, 2024
a74634f
merge
brighthe Nov 14, 2024
3f2944e
reconfiguration soptx
brighthe Nov 17, 2024
862e697
merge
brighthe Nov 17, 2024
f58423f
update
Nov 18, 2024
00e836b
Merge pull request #1347 from Liujiawangmath/develop
cbtxs Nov 18, 2024
27a32af
update
BenHBLiu Nov 18, 2024
b6ec6b3
add Chaos
BenHBLiu Nov 18, 2024
811f300
update
WPengXiang Nov 19, 2024
3e10db3
update
july-liuzhi Nov 19, 2024
ecc022f
Merge remote-tracking branch 'upstream/develop' into develop
july-liuzhi Nov 19, 2024
d65060d
update fracturex
Nov 19, 2024
6a5a164
Merge remote-tracking branch 'upstream/develop' into develop
Nov 19, 2024
599631d
Merge pull request #1351 from cbtxs/develop
cbtxs Nov 19, 2024
8a07a73
update
tiantian0347 Nov 19, 2024
c5d1f9b
Merge remote-tracking branch 'upstream/develop'
tiantian0347 Nov 19, 2024
68d3d09
Merge pull request #1346 from brighthe/develop
weihuayi Nov 19, 2024
4de036b
Merge pull request #1348 from BenHBLiu/develop
weihuayi Nov 19, 2024
e7ead4b
Merge pull request #1349 from WPengXiang/develop
weihuayi Nov 19, 2024
5cffc72
Merge pull request #1350 from july-liuzhi/develop
weihuayi Nov 19, 2024
c4c5c9c
update
brighthe Nov 19, 2024
8f41d5d
merge upstream
brighthe Nov 19, 2024
20f436f
update
BenHBLiu Nov 19, 2024
6e3776c
(mesh/.)triangle/hexahedron/quadrangle_mesh.uniform_refine and (test/…
Mihe0904 Nov 21, 2024
7b2f469
(mesh/.)triangle/hexahedron/quadrangle_mesh.uniform_refine and (test/…
Mihe0904 Nov 21, 2024
83a4fe9
update
tiantian0347 Nov 21, 2024
3f52367
Merge remote-tracking branch 'upstream/develop'
tiantian0347 Nov 21, 2024
b8f5d95
update
WPengXiang Nov 21, 2024
d7b35ea
Merge pull request #1357 from WPengXiang/develop
cbtxs Nov 21, 2024
85d3abc
Merge pull request #1356 from tiantian0347/master
cbtxs Nov 21, 2024
6dc8a03
Merge pull request #1354 from BenHBLiu/develop
cbtxs Nov 21, 2024
b02b64d
Merge pull request #1352 from brighthe/develop
cbtxs Nov 21, 2024
fb28a33
update
WPengXiang Nov 21, 2024
4d38f0c
Merge remote-tracking branch 'upstream/develop' into develop
WPengXiang Nov 21, 2024
409e698
Merge pull request #1358 from WPengXiang/develop
cbtxs Nov 21, 2024
14efa28
Merge pull request #1355 from Mihe0904/develop
weihuayi Nov 21, 2024
25e7d9c
update
brighthe Nov 21, 2024
571c714
merge
brighthe Nov 21, 2024
ce0e51f
BDN
july-liuzhi Nov 21, 2024
f2f121f
Merge remote-tracking branch 'upstream/develop' into develop
july-liuzhi Nov 21, 2024
0e7ba5f
齿轮六面体项目:测试
concha-k-chen Nov 22, 2024
ed3fccf
Merge remote-tracking branch 'upstream/develop' into develop
concha-k-chen Nov 22, 2024
a86a336
update
tiantian0347 Nov 22, 2024
f759299
update
tiantian0347 Nov 22, 2024
a9265fc
update
WPengXiang Nov 22, 2024
d9fc000
Merge remote-tracking branch 'upstream/develop' into develop
WPengXiang Nov 22, 2024
7fdf796
feat(mesh): New utils `inverse_relation` to return the inverse relati…
AlbertZyy Nov 22, 2024
705c522
Merge remote-tracking branch 'upstream/develop' into develop
WPengXiang Nov 23, 2024
c0cc6e8
Merge pull request #1359 from brighthe/develop
weihuayi Nov 23, 2024
2aeaf3f
Merge pull request #1360 from july-liuzhi/develop
weihuayi Nov 23, 2024
ccf4f2f
Merge pull request #1361 from tiantian0347/master
weihuayi Nov 23, 2024
417f563
Merge pull request #1362 from WPengXiang/develop
weihuayi Nov 23, 2024
1f746a5
update
ChaosTHL Nov 23, 2024
371c8cd
-
ChaosTHL Nov 23, 2024
3b5adba
add DCS test
BenHBLiu Nov 23, 2024
5d64113
add DCS
BenHBLiu Nov 23, 2024
7d6a10f
update
BenHBLiu Nov 23, 2024
c0a9156
四边形网格:单位球面上四边形网格类方法实现
concha-k-chen Nov 23, 2024
a86bbf1
Merge remote-tracking branch 'upstream/develop' into develop
concha-k-chen Nov 23, 2024
f18397f
update
brighthe Nov 23, 2024
546dc6e
merge
brighthe Nov 23, 2024
f6220de
Merge pull request #1363 from ChaosTHL/develop
weihuayi Nov 24, 2024
49c6c1e
Merge pull request #1364 from BenHBLiu/develop
weihuayi Nov 24, 2024
65443c3
Merge pull request #1365 from concha-k-chen/develop
weihuayi Nov 24, 2024
da70d4a
Merge pull request #1366 from brighthe/develop
weihuayi Nov 24, 2024
5271be1
update
brighthe Nov 24, 2024
d9ee288
merge
brighthe Nov 24, 2024
ba563e3
update
BenHBLiu Nov 24, 2024
38c21b8
update
BellaLq Nov 25, 2024
d73bcb6
Merge pull request #1367 from brighthe/develop
weihuayi Nov 25, 2024
33f23be
Merge pull request #1368 from BenHBLiu/develop
weihuayi Nov 25, 2024
ec9fed5
Merge pull request #1369 from BellaLq/develop
weihuayi Nov 25, 2024
289e115
update
ChaosTHL Nov 25, 2024
4c85bd3
-
ChaosTHL Nov 25, 2024
cb98c39
-
ChaosTHL Nov 25, 2024
b21b95a
update
july-liuzhi Nov 25, 2024
48e9a85
Merge remote-tracking branch 'upstream/develop' into develop
july-liuzhi Nov 25, 2024
660d031
update
BellaLq Nov 26, 2024
86c07be
update
Nov 26, 2024
0a43b57
Merge remote-tracking branch 'upstream/develop' into develop
Nov 26, 2024
dfe6666
Merge pull request #1372 from cbtxs/develop
cbtxs Nov 26, 2024
5abd063
Merge remote-tracking branch 'upstream/develop' into develop
BellaLq Nov 26, 2024
0960bfd
Merge pull request #1371 from july-liuzhi/develop
cbtxs Nov 26, 2024
952b6ee
Merge branch 'weihuayi:develop' into develop
BellaLq Nov 26, 2024
fb33a4a
update
BenHBLiu Nov 26, 2024
ca74dcc
Merge branch 'develop' of github.com:BenHBLiu/fealpy into develop
BenHBLiu Nov 26, 2024
fcc8e82
Merge pull request #1370 from ChaosTHL/develop
weihuayi Nov 26, 2024
fcd48a1
Merge pull request #1373 from BellaLq/develop
weihuayi Nov 26, 2024
e7c75d7
Merge pull request #1374 from BenHBLiu/develop
weihuayi Nov 26, 2024
d4f5975
fix(mesh): undefined variable in
AlbertZyy Nov 26, 2024
df99100
Merge branch 'develop' of github.com:weihuayi/fealpy into develop
AlbertZyy Nov 26, 2024
dba8c08
update
ChaosTHL Nov 26, 2024
edce1f8
.
ChaosTHL Nov 26, 2024
61d088c
Merge pull request #1375 from ChaosTHL/develop
AlbertZyy Nov 26, 2024
91fb24b
update
Nov 27, 2024
9015adb
Merge remote-tracking branches 'upstream/develop' and 'origin/develop…
Nov 27, 2024
c658add
update
Nov 27, 2024
36a404b
update
BenHBLiu Nov 27, 2024
1df7683
add C-QPSO
BenHBLiu Nov 27, 2024
ca62ca8
Merge pull request #1376 from cbtxs/develop
cbtxs Nov 27, 2024
29f4b80
update
brighthe Nov 27, 2024
13d5b16
merge
brighthe Nov 27, 2024
f94bee5
update
ChaosTHL Nov 27, 2024
a71645d
Merge branch 'develop' of github.com:ChaosTHL/fealpy into develop
ChaosTHL Nov 27, 2024
9965d07
fix(mesh): update coarsen
AlbertZyy Nov 27, 2024
fa4fb2e
Merge pull request #1379 from ChaosTHL/develop
AlbertZyy Nov 27, 2024
9bab589
Merge pull request #1377 from BenHBLiu/develop
AlbertZyy Nov 27, 2024
55b0e5b
Merge pull request #1378 from brighthe/develop
AlbertZyy Nov 27, 2024
a8140b3
fix(backend, mesh): specify context for tensors in `inverse_realtion`…
AlbertZyy Nov 27, 2024
be20cf7
update
BellaLq Nov 27, 2024
d1bb3f9
Merge remote-tracking branch 'upstream/develop' into develop
BellaLq Nov 27, 2024
6621bc5
cm
gaotingyi Nov 28, 2024
9d52062
Merge pull request #1380 from BellaLq/develop
AlbertZyy Nov 28, 2024
1dcaf5c
add MPA
BenHBLiu Nov 28, 2024
4de84aa
update
BenHBLiu Nov 28, 2024
c95e71b
update
gaotingyi Nov 28, 2024
e193c50
更新移动网格
Wangwenbinmath Nov 28, 2024
2c4b9f9
Merge pull request #1381 from gaotingyi/develop
AlbertZyy Nov 28, 2024
8e87387
Merge pull request #1382 from BenHBLiu/develop
AlbertZyy Nov 28, 2024
6940588
Merge pull request #1383 from Wangwenbinmath/develop
AlbertZyy Nov 28, 2024
4c9bdae
update
brighthe Nov 29, 2024
c672aa2
merge
brighthe Nov 29, 2024
9a32d90
add ROA
BenHBLiu Nov 29, 2024
29295de
Merge pull request #1384 from brighthe/develop
AlbertZyy Nov 30, 2024
95cb9e6
Merge pull request #1385 from BenHBLiu/develop
AlbertZyy Nov 30, 2024
b30e313
fix(backend): shape mismatch in `index_add` when `axis` is negative.
AlbertZyy Dec 1, 2024
11b7744
update
BenHBLiu Dec 1, 2024
c9baa2f
Merge pull request #1386 from BenHBLiu/develop
AlbertZyy Dec 2, 2024
94586c1
update
brighthe Dec 3, 2024
f535bfc
merge
brighthe Dec 3, 2024
af4c5a0
update
brighthe Dec 3, 2024
c920854
Merge pull request #1387 from brighthe/develop
AlbertZyy Dec 4, 2024
f06077a
update
brighthe Dec 4, 2024
1f967fb
merge
brighthe Dec 4, 2024
0019433
Merge pull request #1388 from brighthe/develop
AlbertZyy Dec 5, 2024
011d93a
update version to 3.0.2
AlbertZyy Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dist
*.png
*.fig
*.vtk
*.vts
*.so
*.swn
*.swo
Expand Down
41 changes: 20 additions & 21 deletions app/PathPlanning/Grid_maps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from yaml import MappingStartEvent
from fealpy.backend import backend_manager as bm
from fealpy.opt.optimizer_base import opt_alg_options
import scipy.sparse as sp
Expand All @@ -9,26 +8,26 @@

# 二值栅格地图数据
def grid_0():
Map=bm.array([[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0],
[1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1],
[0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1],
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
Map = bm.array([[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0],
[1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0],
[0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0],
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1],
[0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1],
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],
[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
return Map


Expand Down
20 changes: 10 additions & 10 deletions app/PathPlanning/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ def __init__(self, num, NP=20, lb=0, ub=1, MaxIters = 50):
'PSO': ParticleSwarmOpt,
'GWO': GreyWolfOptimizer,
'ACO': AntColonyOptAlg,
# 'HO': HippopotamusOptAlg,
'HO': HippopotamusOptAlg,
# 'CPO': CrestedPorcupineOpt,
'BKA':BlackwingedKiteAlg,
'BOA':ButterflyOptAlg,
'CS':CuckooSearchOpt,
'DE':DifferentialEvolution,
'ETO':ExponentialTrigonometricOptAlg,
'BKA': BlackwingedKiteAlg,
'BOA': ButterflyOptAlg,
'CS': CuckooSearchOpt,
'DE': DifferentialEvolution,
'ETO': ExponentialTrigonometricOptAlg,
}
self.results = {}

Expand Down Expand Up @@ -143,7 +143,7 @@ def optimize(self):
gbest, gbest_f = optimizer.run()
end_time = time.perf_counter()
running_time = end_time - start_time

print(gbest)
result = textMAP.calresult(gbest)
result["path"] = [x for x, y in zip(result["path"], result["path"][1:] + [None]) if x != y]

Expand All @@ -154,7 +154,7 @@ def optimize(self):
}
print(f'The best optimal value by {algo_name} is: {float(gbest_f):.4f} Time: {end_time - start_time:.4f} seconds')

textMAP.printMAP(self.results)
# textMAP.printMAP(self.results)



Expand All @@ -166,5 +166,5 @@ def optimize(self):
tsp_optimizer.optimize()

#Shortest path problem
short_optimizer = ShortestPathApp(num)
short_optimizer.optimize()
# short_optimizer = ShortestPathApp(num)
# short_optimizer.optimize()
8 changes: 4 additions & 4 deletions app/fracturex/fracturex/cases/phase_field/model0_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fealpy.mesh import TriangleMesh
from fealpy.old.geometry.domain_2d import SquareWithCircleHoleDomain

from app.fracturex.fracturex.phasefield.main_solver import MainSolve
from app.fracturex.fracturex.phasefield.main_solve import MainSolve

from fealpy.utils import timer

Expand Down Expand Up @@ -133,7 +133,7 @@ def is_dirchlet_boundary(self, p):
mesh = TriangleMesh.from_domain_distmesh(domain, maxit=100)


ms = MainSolve(mesh=mesh, material_params=model.params, p=p)
ms = MainSolve(mesh=mesh, material_params=model.params)
tmr.send('init')

# 拉伸模型边界条件
Expand All @@ -146,11 +146,11 @@ def is_dirchlet_boundary(self, p):
if bm.backend_name == 'pytorch':
ms.auto_assembly_matrix()


#ms.set_scipy_solver()
ms.output_timer()

ms.save_vtkfile(fname=vtkname)
ms.solve(maxit=maxit)
ms.solve(p=p, maxit=maxit)

tmr.send('stop')
tmr.send(None)
Expand Down
64 changes: 46 additions & 18 deletions app/fracturex/fracturex/cases/phase_field/model3d.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from fealpy.backend import backend_manager as bm
import torch
import numpy as np
from fealpy.mesh import TetrahedronMesh, HexahedronMesh

from app.fracturex.fracturex.phasefield.main_solver import MainSolver
from app.fracturex.fracturex.phasefield.main_solve import MainSolve
from fealpy.utils import timer

import time
Expand Down Expand Up @@ -64,9 +66,10 @@ def is_dirchlet_boundary(self, p):
default='HybridModel', type=str,
help='有限元方法, 默认为 HybridModel.')


parser.add_argument('--mesh_type',
default='tet', type=str,
help='网格类型, 默认为 tet.')
default='tri', type=str,
help='网格类型, 默认为 tri.')

parser.add_argument('--enable_adaptive',
default=False, type=bool,
Expand All @@ -81,8 +84,8 @@ def is_dirchlet_boundary(self, p):
help='网格加密方法, 默认为 bisect.')

parser.add_argument('--n',
default=2, type=int,
help='初始网格加密次数, 默认为 2.')
default=6, type=int,
help='初始网格加密次数, 默认为 6.')

parser.add_argument('--vtkname',
default='test', type=str,
Expand All @@ -92,6 +95,18 @@ def is_dirchlet_boundary(self, p):
default=True, type=bool,
help='是否保存 vtk 文件, 默认为 False.')

parser.add_argument('--force_type',
default='y', type=str,
help='Force type, default is y.')

parser.add_argument('--gpu',
default=False, type=bool,
help='是否使用 GPU, 默认为 False.')

parser.add_argument('--cupy',
default=False, type=bool,
help='是否使用cupy求解.')

args = parser.parse_args()
p= args.degree
maxit = args.maxit
Expand All @@ -101,15 +116,18 @@ def is_dirchlet_boundary(self, p):
marking_strategy = args.marking_strategy
refine_method = args.refine_method
n = args.n
vtkname = args.vtkname
save_vtkfile = args.save_vtkfile
vtkname = args.vtkname +'_' + args.mesh_type + '_'

force_type = args.force_type
gpu = args.gpu
cupy = args.cupy

tmr = timer()
next(tmr)
start = time.time()
bm.set_backend(backend)
if gpu:
bm.set_default_device('cuda')
model = square_with_circular_notch_3d()

if args.mesh_type == 'hex':
Expand All @@ -121,33 +139,43 @@ def is_dirchlet_boundary(self, p):

mesh.uniform_refine(n=n)


fname = args.mesh_type + '_3d_square_with_a_notch_init.vtu'
mesh.to_vtk(fname=fname)

ms = MainSolver(mesh=mesh, material_params=model.params, p=p, model_type=model_type)
ms = MainSolve(mesh=mesh, material_params=model.params, model_type=model_type)
tmr.send('init')

if enable_adaptive:
print('Enable adaptive refinement.')
ms.set_adaptive_refinement(marking_strategy=marking_strategy, refine_method=refine_method)

# 拉伸模型边界条件
ms.add_boundary_condition('force', 'Dirichlet', model.is_force_boundary, model.is_z_force(), 'z')


# 固定位移边界条件
ms.add_boundary_condition('displacement', 'Dirichlet', model.is_dirchlet_boundary, 0)

ms.solve(maxit=maxit, vtkname=vtkname)

if bm.backend_name == 'pytorch':
ms.auto_assembly_matrix()
if cupy:
ms.set_cupy_solver()

ms.output_timer()
ms.save_vtkfile(fname=vtkname)
ms.solve(p=p, maxit=maxit)

tmr.send('stop')
tmr.send(None)
end = time.time()

force = ms.Rforce
disp = ms.force_value
tname = args.mesh_type + '_p' + str(p) + '_' + 'model3d_disp.txt'
force = ms.get_residual_force()
disp = model.is_force()

ftname = 'force_'+args.mesh_type + '_p' + str(p) + '_' + 'model3d_disp.pt'

torch.save(force, ftname)
#np.savetxt('force'+tname, bm.to_numpy(force))
tname = 'params_'+args.mesh_type + '_p' + str(p) + '_' + 'model3d_disp.txt'
with open(tname, 'w') as file:
file.write(f'force: {force},\n time: {end-start},\n degree:{p},\n, backend:{backend},\n, model_type:{model_type},\n, enable_adaptive:{enable_adaptive},\n, marking_strategy:{marking_strategy},\n, refine_method:{refine_method},\n, n:{n},\n, maxit:{maxit},\n, vtkname:{vtkname}\n')
file.write(f'\n time: {end-start},\n degree:{p},\n, backend:{backend},\n, model_type:{model_type},\n, enable_adaptive:{enable_adaptive},\n, marking_strategy:{marking_strategy},\n, refine_method:{refine_method},\n, n:{n},\n, maxit:{maxit},\n, vtkname:{vtkname}\n')
fig, axs = plt.subplots()
plt.plot(disp, force, label='Force')
plt.xlabel('Displacement Increment')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fealpy.mesh import TriangleMesh, QuadrangleMesh


from app.fracturex.fracturex.phasefield.main_solver import MainSolve
from app.fracturex.fracturex.phasefield.main_solve import MainSolve
from fealpy.utils import timer
import time
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -120,6 +120,10 @@ def adaptive_mesh(self, mesh, d0=0.49, d1=1.01, h=0.005):
default=False, type=bool,
help='是否使用 GPU, 默认为 False.')

parser.add_argument('--cupy',
default=False, type=bool,
help='是否使用cupy求解.')

args = parser.parse_args()
p= args.degree
maxit = args.maxit
Expand All @@ -133,6 +137,7 @@ def adaptive_mesh(self, mesh, d0=0.49, d1=1.01, h=0.005):
vtkname = args.vtkname +'_' + args.mesh_type + '_'
force_type = args.force_type
gpu = args.gpu
cupy = args.cupy

tmr = timer()
next(tmr)
Expand Down Expand Up @@ -163,8 +168,7 @@ def adaptive_mesh(self, mesh, d0=0.49, d1=1.01, h=0.005):
fname = args.mesh_type + '_square_with_a_notch_init.vtu'
mesh.to_vtk(fname=fname)


ms = MainSolve(mesh=mesh, material_params=model.params, p=p, model_type=model_type)
ms = MainSolve(mesh=mesh, material_params=model.params, model_type=model_type)
tmr.send('init')

'''
Expand All @@ -189,17 +193,19 @@ def adaptive_mesh(self, mesh, d0=0.49, d1=1.01, h=0.005):

if bm.backend_name == 'pytorch':
ms.auto_assembly_matrix()
if cupy:
ms.set_cupy_solver()

ms.output_timer()
ms.save_vtkfile(fname=vtkname)
ms.solve(maxit=maxit)
ms.solve(p=p, maxit=maxit)

tmr.send('stop')
tmr.send(None)
end = time.time()

force = ms.Rforce
disp = ms.force_value
force = ms.get_residual_force()


ftname = 'force_'+args.mesh_type + '_p' + str(p) + '_' + 'model1_disp.pt'

Expand All @@ -208,6 +214,12 @@ def adaptive_mesh(self, mesh, d0=0.49, d1=1.01, h=0.005):
tname = 'params_'+args.mesh_type + '_p' + str(p) + '_' + 'model1_disp.txt'
with open(tname, 'w') as file:
file.write(f'\n time: {end-start},\n degree:{p},\n, backend:{backend},\n, model_type:{model_type},\n, enable_adaptive:{enable_adaptive},\n, marking_strategy:{marking_strategy},\n, refine_method:{refine_method},\n, n:{n},\n, maxit:{maxit},\n, vtkname:{vtkname}\n')

if force_type == 'y':
disp = model.is_y_force()
elif force_type == 'x':
disp = model.is_x_force()

fig, axs = plt.subplots()
plt.plot(disp, force, label='Force')
plt.xlabel('Displacement Increment')
Expand Down
Loading
Loading