1###############################################################################
2# Copyright (c) Lawrence Livermore National Security, LLC and other Ascent
3# Project developers. See top-level LICENSE AND COPYRIGHT files for dates and
4# other details. No copyright assignment is required to contribute to Ascent.
5###############################################################################
6
7
8import conduit
9import conduit.blueprint
10import ascent
11import numpy as np
12
13
14mesh = conduit.Node()
15conduit.blueprint.mesh.examples.braid("hexs",
16                                      25,
17                                      25,
18                                      25,
19                                      mesh)
20
21# Use Ascent to clip and threshold data
22a = ascent.Ascent()
23a.open()
24
25# publish mesh to ascent
26a.publish(mesh);
27
28# setup actions
29actions = conduit.Node()
30add_act = actions.append()
31add_act["action"] = "add_pipelines"
32pipelines = add_act["pipelines"]
33
34# create a  pipeline (pl1) with a threshold filter (f1)
35# and a clip filter (f2)
36
37# add our threshold (f1)
38pipelines["pl1/f1/type"] = "threshold"
39thresh_params = pipelines["pl1/f1/params"]
40# set threshold parameters
41# keep elements with values between 0.0 and 0.5
42thresh_params["field"]  = "braid"
43thresh_params["min_value"] = 0.0
44thresh_params["max_value"] = 0.5
45
46# add our clip (f2)
47pipelines["pl1/f2/type"]   = "clip"
48clip_params = pipelines["pl1/f2/params"]
49# set clip parameters
50# use spherical clip
51clip_params["sphere/center/x"] = 0.0
52clip_params["sphere/center/y"] = 0.0
53clip_params["sphere/center/z"] = 0.0
54clip_params["sphere/radius"]   = 12
55
56#  declare a scene to render the pipeline results
57add_act2 = actions.append()
58add_act2["action"] = "add_scenes"
59scenes = add_act2["scenes"]
60
61# add a scene (s1) with one pseudocolor plot (p1) that
62# will render the result of our pipeline (pl1)
63scenes["s1/plots/p1/type"] = "pseudocolor"
64scenes["s1/plots/p1/pipeline"] = "pl1"
65scenes["s1/plots/p1/field"] = "braid"
66# set the output file name (ascent will add ".png")
67scenes["s1/image_name"] = "out_pipeline_ex2_thresh_clip"
68
69# print our full actions tree
70print(actions.to_yaml())
71
72# execute
73a.execute(actions)
74
75# close ascent
76a.close()
77