16#include <Champ_implementation_P1.h>
17#include <Domaine_Poly_base.h>
18#include <Octree_Double.h>
21double Champ_implementation_P1::form_function(
const ArrOfDouble& position,
const IntTab& les_elems,
const DoubleTab& nodes, ArrOfInt& index,
int cell,
int ddl)
const
23 int nb_nodes_per_cell = les_elems.
dimension(1);
24 assert(ddl < nb_nodes_per_cell);
26 for (
int i = 0; i < nb_nodes_per_cell; i++)
27 index[i] = les_elems(cell, (i + ddl) % nb_nodes_per_cell);
29 if (nb_nodes_per_cell == 2)
35 num += (position[d] - nodes(index[0], d)) * (position[d] - nodes(index[0], d));
36 den += (nodes(index[1], d) - nodes(index[0], d)) * (nodes(index[1], d) - nodes(index[0], d));
38 double res = 1. - sqrt(num / den);
47 den = (nodes(index[2], 0) - nodes(index[1], 0)) * (nodes(index[0], 1) - nodes(index[1], 1)) - (nodes(index[2], 1) - nodes(index[1], 1)) * (nodes(index[0], 0) - nodes(index[1], 0));
49 num = (nodes(index[2], 0) - nodes(index[1], 0)) * (position[1] - nodes(index[1], 1)) - (nodes(index[2], 1) - nodes(index[1], 1)) * (position[0] - nodes(index[1], 0));
53 double xp = (nodes(index[2], 1) - nodes(index[1], 1)) * (nodes(index[0], 2) - nodes(index[1], 2)) - (nodes(index[2], 2) - nodes(index[1], 2)) * (nodes(index[0], 1) - nodes(index[1], 1));
55 double yp = (nodes(index[2], 2) - nodes(index[1], 2)) * (nodes(index[0], 0) - nodes(index[1], 0)) - (nodes(index[2], 0) - nodes(index[1], 0)) * (nodes(index[0], 2) - nodes(index[1], 2));
57 double zp = (nodes(index[2], 0) - nodes(index[1], 0)) * (nodes(index[0], 1) - nodes(index[1], 1)) - (nodes(index[2], 1) - nodes(index[1], 1)) * (nodes(index[0], 0) - nodes(index[1], 0));
59 den = xp * (nodes(index[3], 0) - nodes(index[1], 0)) + yp * (nodes(index[3], 1) - nodes(index[1], 1)) + zp * (nodes(index[3], 2) - nodes(index[1], 2));
61 xp = (nodes(index[2], 1) - nodes(index[1], 1)) * (position[2] - nodes(index[1], 2)) - (nodes(index[2], 2) - nodes(index[1], 2)) * (position[1] - nodes(index[1], 1));
63 yp = (nodes(index[2], 2) - nodes(index[1], 2)) * (position[0] - nodes(index[1], 0)) - (nodes(index[2], 0) - nodes(index[1], 0)) * (position[2] - nodes(index[1], 2));
65 zp = (nodes(index[2], 0) - nodes(index[1], 0)) * (position[1] - nodes(index[1], 1)) - (nodes(index[2], 1) - nodes(index[1], 1)) * (position[0] - nodes(index[1], 0));
67 num = xp * (nodes(index[3], 0) - nodes(index[1], 0)) + yp * (nodes(index[3], 1) - nodes(index[1], 1)) + zp * (nodes(index[3], 2) - nodes(index[1], 2));
71 Cerr <<
"Error in Champ_implementation_P1::form_function : Invalid dimension" << finl;
76 double result = num / den;
80 Cerr <<
"WARNING: The barycentric coordinate of point :" << finl;
81 Cerr <<
"x= " << position[0] <<
" y=" << position[1];
84 Cerr <<
" z=" << position[3];
87 Cerr <<
"is not between 0 and 1 : " << result << finl;
88 Cerr <<
"On the element " << cell <<
" of the processor " <<
Process::me() << finl;
102 const IntTab& les_elems = domaine.les_elems();
103 const DoubleTab& nodes = domaine.les_sommets();
104 const int nb_nodes_per_cell = domaine.nb_som_elem(), N = resu.
line_size();
105 ArrOfInt index(nb_nodes_per_cell);
111 const DoubleVect& ve = zpoly->
volumes();
113 for (
int ic = 0; ic < cells.
size_array(); ic++)
115 int cell = cells[ic];
121 for (
int j = 0, k = es_d(cell); k < es_d(cell + 1); j++, k++)
122 resu(ic) += values(les_elems(cell, j), ncomp) * v_es(k) / ve(cell);
126 for (
int j = 0, k = es_d(cell); k < es_d(cell + 1); k++)
127 for (
int n = 0, s = les_elems(cell, j); n < N; n++)
128 resu(ic, n) += values(s, n) * v_es(k) / ve(cell);
134 for (
int ic = 0; ic < cells.
size_array(); ic++)
136 int cell = cells[ic];
140 position[k] = positions(ic, k);
146 for (
int j = 0; j < nb_nodes_per_cell; j++)
148 int node = les_elems(cell, j);
149 resu(ic) += values(node, ncomp) * form_function(position, les_elems, nodes, index, cell, j);
156 for (
int j = 0; j < nb_nodes_per_cell; j++)
158 double weight = form_function(position, les_elems, nodes, index, cell, j);
159 int node = les_elems(cell, j);
160 for (
int k = 0; k < N; k++)
161 resu(ic, k) += values(node, k) * weight;
184 Octree_Double octree;
189 input >> nb_val_lues;
191 const int tmp_size = dim + nb_comp;
192 ArrOfDouble tmp(tmp_size);
193 ArrOfDouble node_coord;
198 ArrOfInt count(dom.
nb_som());
200 for (
int i_val = 0; i_val < nb_val_lues; i_val++)
202 input.
get(tmp.
addr(), tmp_size);
209 Cerr <<
"Error in Champ_som_lu::readOn: point " << node_coord <<
" corresponds to " << node_list.
size_array() <<
" nodes in the geometry within the specified tolerance" << finl;
214 const int node_index = node_list[0];
216 for (
int i = 0; i < nb_comp; i++)
217 val(node_index, i) = tmp[dim + i];
225 if (dom.
nb_som() > 0 && min_array(count) == 0)
227 Cerr <<
"Error in Champ_som_lu::readOn: some coordinates were not found in the file" << finl;
247double coord_barycentrique_P1(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
int le_poly,
int i)
252 if (nb_som_elem == 3)
253 return coord_barycentrique_P1_triangle(polys, coord, x, y, le_poly, i);
255 else if (nb_som_elem == 4)
256 return coord_barycentrique_P1_rectangle(polys, coord, x, y, le_poly, i);
257 Cerr <<
"The number of nodes by element " << nb_som_elem <<
" does not correspond to a treated situation in the coord_barycentrique_P1 function." << finl;
279double coord_barycentrique_P1(
const IntTab& polys,
const DoubleTab& coord,
double x,
double y,
double z,
int le_poly,
int i)
284 if (nb_som_elem == 4)
285 return coord_barycentrique_P1_tetraedre(polys, coord, x, y, z, le_poly, i);
286 else if (nb_som_elem == 8)
287 return coord_barycentrique_P1_hexaedre(polys, coord, x, y, z, le_poly, i);
288 Cerr <<
"The number of nodes by element " << nb_som_elem <<
" does not correspond to a treated situation in the coord_barycentrique_P1 function." << finl;
static void init_from_file(DoubleTab &val, const Domaine &dom, int nb_comp, double tolerance, Entree &input)
Initializes the array of values at the vertices of domain dom from values read from "input".
void value_interpolation(const DoubleTab &positions, const ArrOfInt &cells, const DoubleTab &values, DoubleTab &resu, int ncomp=-1) const override
const Domaine & get_domaine_geom() const
const Domaine_VF & get_domaine_dis() const
const DoubleTab_t & coord_sommets() const
virtual void creer_tableau_sommets(Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT) const
Creates an array with one "row" per mesh vertex.
int_t nb_som() const
Returns the number of vertices of the domain.
const DoubleTab & vol_elem_som() const
const IntTab & elem_som_d() const
double volumes(int i) const
Class defining operators and methods for all reading operation in an input flow (file,...
virtual int get(int *ob, std::streamsize n)
static double precision_geom
static int_t search_nodes_close_to(double x, double y, double z, const DoubleTab_t &coords, ArrOfInt_t &node_list, double epsilon)
Non-member method. Searches among the vertices in node_list for those within a distance.
void build_nodes(const DoubleTab_t &coords, const bool include_virtual, const double epsilon=0.)
builds an octree containing the points with coordinates coords.
int_t search_elements_box(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax, ArrOfInt_t &elements) const
searches for all elements or points potentially having a non-empty intersection with the given box.
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
_SIZE_ size_array() const
virtual void ref_array(TRUSTArray &, _SIZE_ start=0, _SIZE_ sz=-1)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")