libMesh
Loading...
Searching...
No Matches
dtk_evaluator.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18#include "libmesh/libmesh_config.h"
19
20#ifdef LIBMESH_TRILINOS_HAVE_DTK
21
22#include "libmesh/dtk_evaluator.h"
23
24#include "libmesh/dof_map.h"
25#include "libmesh/fe_interface.h"
26#include "libmesh/fe_compute_data.h"
27#include "libmesh/numeric_vector.h"
28#include "libmesh/equation_systems.h"
29#include "libmesh/system.h"
30
31namespace libMesh
32{
33
35 std::string var_name):
36 sys(in_sys),
37 current_local_solution(*sys.current_local_solution),
38 es(in_sys.get_equation_systems()),
39 mesh(sys.get_mesh()),
40 dim(mesh.mesh_dimension()),
41 dof_map(sys.get_dof_map()),
42 var_num(sys.variable_number(var_name)),
43 fe_type(dof_map.variable_type(var_num))
44{}
45
47DTKEvaluator::evaluate(const Teuchos::ArrayRCP<int> & elements,
48 const Teuchos::ArrayRCP<double> & coords)
49{
50 unsigned int num_values = elements.size();
51
52 Teuchos::ArrayRCP<Number> values(num_values);
53 DataTransferKit::FieldContainer<Number> evaluations(values, 1);
54
55 for (unsigned int i=0; i<num_values; i++)
56 {
57 Elem * elem = mesh.elem_ptr(elements[i]);
58
59 Point p;
60
61 for (unsigned int j=0; j<dim; j++)
62 p(j) = coords[(j*num_values)+i];
63
64 const Point mapped_point(FEMap::inverse_map(dim, elem, p));
65
66 FEComputeData data (es, mapped_point);
68
69 std::vector<dof_id_type> dof_indices;
70 dof_map.dof_indices(elem, dof_indices, var_num);
71
72 Number value = 0;
73
74 for (auto j : index_range(dof_indices))
75 value += current_local_solution(dof_indices[j]) * data.shape[j];
76
77 values[i] = value;
78 }
79
80 return evaluations;
81}
82
83} // namespace libMesh
84
85#endif
unsigned int dim
DataTransferKit::FieldContainer< Number > FieldContainerType
DTKEvaluator(System &in_sys, std::string var_name)
virtual FieldContainerType evaluate(const Teuchos::ArrayRCP< int > &elements, const Teuchos::ArrayRCP< double > &coords) override
EquationSystems & es
const FEType & fe_type
NumericVector< Number > & current_local_solution
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2201
This is the base class from which all geometric element types are derived.
Definition elem.h:96
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
std::vector< Number > shape
Storage for the computed shape function values.
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data,...
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition fe_map.C:1512
virtual const Elem * elem_ptr(const dof_id_type i) const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
static const bool value
Definition xdr_io.C:55