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

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1