/
cavity.C
137 lines (106 loc) · 4.04 KB
/
cavity.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//-----------------------------------------------------------------------bl-
//--------------------------------------------------------------------------
//
// GRINS - General Reacting Incompressible Navier-Stokes
//
// Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
// Copyright (C) 2010-2013 The PECOS Development Team
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the Version 2.1 GNU Lesser General
// Public License as published by the Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc. 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA
//
//-----------------------------------------------------------------------el-
#include "grins_config.h"
#include <iostream>
// GRINS
#include "grins/simulation.h"
#include "grins/simulation_builder.h"
// GRVY
#ifdef GRINS_HAVE_GRVY
#include "grvy.h"
#endif
// libMesh
#include "libmesh/parallel.h"
// Function for getting initial temperature field
libMesh::Real
initial_values( const libMesh::Point& p, const libMesh::Parameters ¶ms,
const std::string& system_name, const std::string& unknown_name );
int main(int argc, char* argv[])
{
#ifdef GRINS_USE_GRVY_TIMERS
GRVY::GRVY_Timer_Class grvy_timer;
grvy_timer.Init("GRINS Timer");
#endif
// Check command line count.
if( argc < 2 )
{
// TODO: Need more consistent error handling.
std::cerr << "Error: Must specify libMesh input file." << std::endl;
exit(1); // TODO: something more sophisticated for parallel runs?
}
// libMesh input file should be first argument
std::string libMesh_input_filename = argv[1];
// Create our GetPot object.
GetPot libMesh_inputfile( libMesh_input_filename );
#ifdef GRINS_USE_GRVY_TIMERS
grvy_timer.BeginTimer("Initialize Solver");
#endif
// Initialize libMesh library.
libMesh::LibMeshInit libmesh_init(argc, argv);
GRINS::SimulationBuilder sim_builder;
GRINS::Simulation grins( libMesh_inputfile,
sim_builder,
libmesh_init.comm() );
//FIXME: We need to move this to within the Simulation object somehow...
std::string restart_file = libMesh_inputfile( "restart-options/restart_file", "none" );
if( restart_file == "none" )
{
// Asssign initial temperature value
std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
const libMesh::System& system = es->get_system(system_name);
libMesh::Parameters ¶ms = es->parameters;
libMesh::Real T_init = libMesh_inputfile("Physics/LowMachNavierStokes/T0", 0.0);
libMesh::Real p0_init = libMesh_inputfile("Physics/LowMachNavierStokes/p0", 0.0);
libMesh::Real& dummy_T = params.set<libMesh::Real>("T_init");
dummy_T = T_init;
libMesh::Real& dummy_p0 = params.set<libMesh::Real>("p0_init");
dummy_p0 = p0_init;
system.project_solution( initial_values, NULL, params );
}
#ifdef GRINS_USE_GRVY_TIMERS
grvy_timer.EndTimer("Initialize Solver");
// Attach GRVY timer to solver
grins.attach_grvy_timer( &grvy_timer );
#endif
grins.run();
#ifdef GRINS_USE_GRVY_TIMERS
grvy_timer.Finalize();
if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
#endif
return 0;
}
libMesh::Real
initial_values( const libMesh::Point&, const libMesh::Parameters ¶ms,
const std::string& , const std::string& unknown_name )
{
libMesh::Real value = 0.0;
if( unknown_name == "T" )
value = params.get<libMesh::Real>("T_init");
else if( unknown_name == "p0" )
value = params.get<libMesh::Real>("p0_init");
else
value = 0.0;
return value;
}