GRINS-0.8.0
parsed_property_base.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 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 #ifndef GRINS_PARSED_PROPERTY_BASE_H
26 #define GRINS_PARSED_PROPERTY_BASE_H
27 
28 //GRINS
29 #include "grins/assembly_context.h"
30 #include "grins/parameter_user.h"
31 
32 // libMesh
33 #include "libmesh/libmesh_common.h"
34 #include "libmesh/fem_system.h"
35 #include "libmesh/parsed_function.h"
36 #include "libmesh/point.h"
37 
38 // C++
39 #include <string>
40 
41 namespace GRINS
42 {
44 
48  {
49  public:
50 
52  virtual ~ParsedPropertyBase(){};
53 
54  libMesh::Real operator()(AssemblyContext& context, unsigned int qp) const;
55 
56  libMesh::Real operator()( const libMesh::Point& p, const libMesh::Real time );
57 
58  virtual void init(libMesh::FEMSystem* /*system*/){};
59 
60  protected:
61 
63 
66  bool check_func_nonzero( const std::string& function ) const;
67 
68  // User specified parsed function
70 
71  };
72 
73  /* ------------------------- Inline Functions -------------------------*/
74  inline
75  libMesh::Real ParsedPropertyBase::operator()(AssemblyContext& context, unsigned int qp) const
76  {
77  // FIXME: We should be getting the variable index to get the qps from the context
78  // not hardcode it to be 0
79  const std::vector<libMesh::Point>& x = context.get_element_fe(0)->get_xyz();
80 
81  const libMesh::Point& x_qp = x[qp];
82 
83  // libMesh API here sucks - RHS
86  libMesh::Number value = mutable_func(x_qp,context.time);
87 
88  return value;
89  }
90 
91  inline
92  libMesh::Real ParsedPropertyBase::operator()( const libMesh::Point& p, const libMesh::Real time )
93  {
94  return _func(p,time);
95  }
96 
97 } // end namespace GRINS
98 
99 #endif // GRINS_PARSED_PROPERTY_BASE_H
libMesh::ParsedFunction< libMesh::Number > _func
virtual void init(libMesh::FEMSystem *)
bool check_func_nonzero(const std::string &function) const
Returns true if function string is nonzero.
GRINS namespace.
Base class for material properties based on ParsedFunction.
libMesh::Real operator()(AssemblyContext &context, unsigned int qp) const

Generated on Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1