File tree Expand file tree Collapse file tree 4 files changed +46
-13
lines changed Expand file tree Collapse file tree 4 files changed +46
-13
lines changed Original file line number Diff line number Diff line change @@ -150,18 +150,9 @@ def poisson_ref_compute_func(_in):
150
150
validator = {residual_validator .name : residual_validator }
151
151
152
152
# set visualizer(optional)
153
- NPOINT_BC = NPOINT_TOP + NPOINT_BOTTOM + NPOINT_LEFT + NPOINT_RIGHT
154
- vis_interior_points = geom ["rect" ].sample_interior (NPOINT_PDE , evenly = True )
155
- vis_boundary_points = geom ["rect" ].sample_boundary (NPOINT_BC , evenly = True )
156
-
157
153
# manually collate input data for visualization,
158
- # interior+boundary
159
- vis_points = {}
160
- for key in vis_interior_points :
161
- vis_points [key ] = np .concatenate (
162
- (vis_interior_points [key ], vis_boundary_points [key ])
163
- )
164
-
154
+ NPOINT_BC = NPOINT_TOP + NPOINT_BOTTOM + NPOINT_LEFT + NPOINT_RIGHT
155
+ vis_points = geom ["rect" ].sample_interior (NPOINT_PDE + NPOINT_BC , evenly = True )
165
156
visualizer = {
166
157
"visulzie_u_v" : ppsci .visualize .VisualizerVtu (
167
158
vis_points ,
@@ -194,6 +185,7 @@ def poisson_ref_compute_func(_in):
194
185
solver .visualize ()
195
186
196
187
# directly evaluate pretrained model(optional)
188
+ logger .init_logger ("ppsci" , f"{ output_dir } /eval.log" , "info" )
197
189
solver = ppsci .solver .Solver (
198
190
model ,
199
191
constraint ,
Original file line number Diff line number Diff line change 30
30
"Laplace" ,
31
31
"NavierStokes" ,
32
32
"NormalDotVec" ,
33
- "Vibration" ,
34
33
"Poisson" ,
34
+ "Vibration" ,
35
35
"build_equation" ,
36
36
]
37
37
Original file line number Diff line number Diff line change 26
26
"Laplace" ,
27
27
"NavierStokes" ,
28
28
"NormalDotVec" ,
29
- "Vibration" ,
30
29
"Poisson" ,
30
+ "Vibration" ,
31
31
]
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from ppsci .autodiff import hessian
16
+ from ppsci .equation .pde import base
17
+
18
+
19
+ class Poisson (base .PDE ):
20
+ """Poisson
21
+
22
+ Args:
23
+ dim (int): Dimension of equation.
24
+
25
+ Examples:
26
+ >>> import ppsci
27
+ >>> pde = ppsci.equation.Poisson(2)
28
+ """
29
+
30
+ def __init__ (self , dim : int ):
31
+ super ().__init__ ()
32
+ self .dim = dim
33
+
34
+ def poisson_compute_func (out ):
35
+ invars = ("x" , "y" , "z" )[: self .dim ]
36
+ poisson = 0
37
+ for invar in invars :
38
+ poisson += hessian (out ["p" ], out [invar ])
39
+ return poisson
40
+
41
+ self .add_equation ("poisson" , poisson_compute_func )
You can’t perform that action at this time.
0 commit comments