MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
visualizer.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details
11
12#include "visualizer.hpp"
13#include <string>
14
15namespace mfem
16{
17namespace spde
18{
19
21{
22 ParaViewDataCollection paraview_dc("SurrogateMaterial", mesh_);
23 paraview_dc.SetPrefixPath("ParaView");
24 paraview_dc.SetLevelsOfDetail(order_);
25 paraview_dc.SetCycle(0);
27 paraview_dc.SetHighOrderOutput(true);
28 paraview_dc.SetTime(0.0); // set the time
29 paraview_dc.RegisterField("random_field", &g1_);
30 if (is_3D_)
31 {
32 paraview_dc.RegisterField("topological_support", &g2_);
33 paraview_dc.RegisterField("imperfect_topology", &g3_);
34 paraview_dc.RegisterField("level_set", &g4_);
35 }
36 paraview_dc.Save();
37}
38
40{
41 std::string vishost{"localhost"};
42 int visport = 19916;
43 int num_procs = Mpi::WorldSize();
44 int process_rank = Mpi::WorldRank();
45 socketstream uout;
46 std::ostringstream oss_u;
47 uout.open(vishost.c_str(), visport);
48 uout.precision(8);
49 oss_u.str("");
50 oss_u.clear();
51 oss_u << "Random Field";
52 uout << "parallel " << num_procs << " " << process_rank << "\n"
53 << "solution\n"
54 << *mesh_ << g1_ << "window_geometry 0 20 400 350 "
55 << "window_title '" << oss_u.str() << "'" << std::flush;
56 uout.close();
57
58 if (!is_3D_)
59 {
60 return;
61 }
62
63 socketstream vout;
64 std::ostringstream oss_v;
65 vout.open(vishost.c_str(), visport);
66 vout.precision(8);
67 oss_v.str("");
68 oss_v.clear();
69 oss_v << "Topological Support";
70 vout << "parallel " << num_procs << " " << process_rank << "\n"
71 << "solution\n"
72 << *mesh_ << g2_ << "window_geometry 403 20 400 350 "
73 << "window_title '" << oss_v.str() << "'" << std::flush;
74 vout.close();
75
76 socketstream wout;
77 std::ostringstream oss_w;
78 wout.open(vishost.c_str(), visport);
79 wout.precision(8);
80 oss_w.str("");
81 oss_w.clear();
82 oss_w << "Imperfect Topology";
83 wout << "parallel " << num_procs << " " << process_rank << "\n"
84 << "solution\n"
85 << *mesh_ << g3_ << "window_geometry 0 420 400 350 "
86 << "window_title '" << oss_w.str() << "'" << std::flush;
87 wout.close();
88
89 socketstream lout;
90 std::ostringstream oss_l;
91 lout.open(vishost.c_str(), visport);
92 lout.precision(8);
93 oss_l.str("");
94 oss_l.clear();
95 oss_l << "Level Set";
96 lout << "parallel " << num_procs << " " << process_rank << "\n"
97 << "solution\n"
98 << *mesh_ << g4_ << "window_geometry 403 420 400 350 "
99 << "window_title '" << oss_l.str() << "'" << std::flush;
100 lout.close();
101}
102
103} // namespace spde
104} // namespace mfem
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
void SetPrefixPath(const std::string &prefix)
Set the path where the DataCollection will be saved.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
Helper class for ParaView visualization data.
void SetHighOrderOutput(bool high_order_output_)
void SetLevelsOfDetail(int levels_of_detail_)
virtual void Save() override
void SetDataFormat(VTKFormat fmt)
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
int close()
Close the socketstream.
void SendToGLVis() const
const int visport
const char vishost[]