8 #if !defined(KRATOS_VOLUME_AVERAGING_TOOL )
9 #define KRATOS_VOLUME_AVERAGING_TOOL
63 template<std::
size_t TDim >
123 virtual std::string
Info()
const
193 double x0 = geom[0].X();
194 double y0 = geom[0].Y();
195 double x1 = geom[1].X();
196 double y1 = geom[1].Y();
197 double x2 = geom[2].X();
198 double y2 = geom[2].Y();
201 xc = 0.3333333333333333333*(x0+
x1+
x2);
202 yc = 0.3333333333333333333*(y0+y1+y2);
205 double R1 = (
xc-x0)*(
xc-x0) + (
yc-y0)*(
yc-y0);
217 inline void CalculateCenterAndSearchRadius(Geometry<Node >&geom,
218 double&
xc,
double&
yc,
double& zc,
double&
R, array_1d<double,4>&
N
222 double x0 = geom[0].X();
223 double y0 = geom[0].Y();
224 double z0 = geom[0].Z();
225 double x1 = geom[1].X();
226 double y1 = geom[1].Y();
227 double z1 = geom[1].Z();
228 double x2 = geom[2].X();
229 double y2 = geom[2].Y();
230 double z2 = geom[2].Z();
231 double x3 = geom[3].X();
232 double y3 = geom[3].Y();
233 double z3 = geom[3].Z();
237 yc = 0.25*(y0+y1+y2+y3);
238 zc = 0.25*(z0+z1+z2+z3);
240 double R1 = (
xc-x0)*(
xc-x0) + (
yc-y0)*(
yc-y0) + (zc-z0)*(zc-z0);
241 double R2 = (
xc-
x1)*(
xc-
x1) + (
yc-y1)*(
yc-y1) + (zc-z1)*(zc-z1);
242 double R3 = (
xc-
x2)*(
xc-
x2) + (
yc-y2)*(
yc-y2) + (zc-z2)*(zc-z2);
243 double R4 = (
xc-x3)*(
xc-x3) + (
yc-y3)*(
yc-y3) + (zc-z3)*(zc-z3);
254 inline double CalculateVol(
const double x0,
const double y0,
255 const double x1,
const double y1,
256 const double x2,
const double y2
259 return 0.5*( (
x1-x0)*(y2-y0)- (y1-y0)*(
x2-x0) );
263 inline double CalculateVol(
const double x0,
const double y0,
const double z0,
264 const double x1,
const double y1,
const double z1,
265 const double x2,
const double y2,
const double z2,
266 const double x3,
const double y3,
const double z3
269 double x10 =
x1 - x0;
270 double y10 = y1 - y0;
271 double z10 = z1 - z0;
273 double x20 =
x2 - x0;
274 double y20 = y2 - y0;
275 double z20 = z2 - z0;
277 double x30 = x3 - x0;
278 double y30 = y3 - y0;
279 double z30 = z3 - z0;
281 double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
282 return detJ*0.1666666666666666666667;
288 inline bool CalculatePosition( Geometry<Node >&geom,
289 const double xc,
const double yc,
const double zc,
290 array_1d<double,3>&
N
293 double x0 = geom[0].X();
294 double y0 = geom[0].Y();
295 double x1 = geom[1].X();
296 double y1 = geom[1].Y();
297 double x2 = geom[2].X();
298 double y2 = geom[2].Y();
300 double area = CalculateVol(x0,y0,
x1,y1,
x2,y2);
301 double inv_area = 0.0;
302 if (std::abs(area) < std::numeric_limits<double>::epsilon()) {
308 inv_area = 1.0 / area;
311 N[0] = CalculateVol(
x1,y1,
x2,y2,
xc,
yc) * inv_area;
312 N[1] = CalculateVol(
x2,y2,x0,y0,
xc,
yc) * inv_area;
313 N[2] = CalculateVol(x0,y0,
x1,y1,
xc,
yc) * inv_area;
316 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[0] <=1.0 &&
N[1]<= 1.0 &&
N[2] <= 1.0)
325 inline bool CalculatePosition( Geometry<Node >&geom,
326 const double xc,
const double yc,
const double zc,
327 array_1d<double,4>&
N
331 double x0 = geom[0].X();
332 double y0 = geom[0].Y();
333 double z0 = geom[0].Z();
334 double x1 = geom[1].X();
335 double y1 = geom[1].Y();
336 double z1 = geom[1].Z();
337 double x2 = geom[2].X();
338 double y2 = geom[2].Y();
339 double z2 = geom[2].Z();
340 double x3 = geom[3].X();
341 double y3 = geom[3].Y();
342 double z3 = geom[3].Z();
344 double vol = CalculateVol(x0,y0,z0,
x1,y1,z1,
x2,y2,z2,x3,y3,z3);
346 double inv_vol = 0.0;
347 if (vol < 0.0000000000001)
358 N[0] = CalculateVol(
x1,y1,z1,x3,y3,z3,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
359 N[1] = CalculateVol(x3,y3,z3,x0,y0,z0,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
360 N[2] = CalculateVol(x3,y3,z3,
x1,y1,z1,x0,y0,z0,
xc,
yc,zc) * inv_vol;
361 N[3] = CalculateVol(x0,y0,z0,
x1,y1,z1,
x2,y2,z2,
xc,
yc,zc) * inv_vol;
364 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >=0.0 &&
365 N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <=1.0)
379 Element::Pointer el_it,
380 const array_1d<double,3>&
N,
382 Variable<array_1d<double,3> >& rOriginVariable,
383 Variable<array_1d<double,3> >& rDestinationVariable)
387 Geometry< Node >& geom = el_it->GetGeometry();
394 array_1d<double,3>& step_data = (pnode)->FastGetSolutionStepValue(rDestinationVariable, 0);
396 const array_1d<double,3>& node0_data = geom[0].FastGetSolutionStepValue(rOriginVariable, 0);
397 const array_1d<double,3>& node1_data = geom[1].FastGetSolutionStepValue(rOriginVariable, 0);
398 const array_1d<double,3>& node2_data = geom[2].FastGetSolutionStepValue(rOriginVariable, 0);
401 for (
unsigned int j= 0;
j< TDim;
j++)
403 step_data[
j] =
N[0] * node0_data[
j] +
N[1] * node1_data[
j] +
N[2] * node2_data[
j];
415 Element::Pointer el_it,
416 const array_1d<double,4>&
N,
418 Variable<array_1d<double,3> >& rOriginVariable,
419 Variable<array_1d<double,3> >& rDestinationVariable) {
422 Geometry< Node >& geom = el_it->GetGeometry();
425 array_1d<double, 3 > & step_data = (pnode)->FastGetSolutionStepValue(rDestinationVariable, 0);
426 const array_1d<double, 3 > & node0_data = geom[0].FastGetSolutionStepValue(rOriginVariable, 0);
427 const array_1d<double, 3 > & node1_data = geom[1].FastGetSolutionStepValue(rOriginVariable, 0);
428 const array_1d<double, 3 > & node2_data = geom[2].FastGetSolutionStepValue(rOriginVariable, 0);
429 const array_1d<double, 3 > & node3_data = geom[3].FastGetSolutionStepValue(rOriginVariable, 0);
432 for (
unsigned int j = 0;
j < TDim;
j++) {
433 step_data[
j] =
N[0] * node0_data[
j] +
N[1] * node1_data[
j] +
N[2] * node2_data[
j] +
N[3] * node3_data[
j];
440 Element::Pointer el_it,
441 const array_1d<double,3>&
N,
443 Variable<double>& rOriginVariable,
444 Variable<double>& rDestinationVariable) {
447 Geometry< Node >& geom = el_it->GetGeometry();
451 double& step_data = (pnode)->FastGetSolutionStepValue(rDestinationVariable, 0);
452 const double node0_data = geom[0].FastGetSolutionStepValue(rOriginVariable, 0);
453 const double node1_data = geom[1].FastGetSolutionStepValue(rOriginVariable, 0);
454 const double node2_data = geom[2].FastGetSolutionStepValue(rOriginVariable, 0);
458 step_data =
N[0] * node0_data +
N[1] * node1_data +
N[2] * node2_data;
466 Element::Pointer el_it,
467 const array_1d<double,4>&
N,
469 Variable<double>& rOriginVariable,
470 Variable<double>& rDestinationVariable)
473 Geometry< Node >& geom = el_it->GetGeometry();
478 double& step_data = (pnode)->FastGetSolutionStepValue(rDestinationVariable, 0);
479 const double node0_data = geom[0].FastGetSolutionStepValue(rOriginVariable, 0);
480 const double node1_data = geom[1].FastGetSolutionStepValue(rOriginVariable, 0);
481 const double node2_data = geom[2].FastGetSolutionStepValue(rOriginVariable, 0);
482 const double node3_data = geom[3].FastGetSolutionStepValue(rOriginVariable, 0);
486 step_data =
N[0] * node0_data +
N[1] * node1_data +
N[2] * node2_data +
N[3] * node3_data;
493 Element::Pointer el_it,
494 const array_1d<double,3>&
N,
496 Variable<array_1d<double,3> >& rDestinationVariable,
497 Variable<array_1d<double,3> >& rOriginVariable,
498 int n_particles_per_depth_distance) {
501 Geometry< Node >& geom = el_it->GetGeometry();
505 const array_1d<double, 3 > & step_data = (pnode)->FastGetSolutionStepValue(rOriginVariable, 0);
506 array_1d<double, 3 > & node0_data = geom[0].FastGetSolutionStepValue(rDestinationVariable, 0);
507 array_1d<double, 3 > & node1_data = geom[1].FastGetSolutionStepValue(rDestinationVariable, 0);
508 array_1d<double, 3 > & node2_data = geom[2].FastGetSolutionStepValue(rDestinationVariable, 0);
511 for (
unsigned int j = 0;
j < TDim;
j++) {
512 origin_data = step_data[
j];
513 node0_data[
j] += -
N[0] * origin_data * n_particles_per_depth_distance;
514 node1_data[
j] += -
N[1] * origin_data * n_particles_per_depth_distance;
515 node2_data[
j] += -
N[2] * origin_data * n_particles_per_depth_distance;
524 Element::Pointer el_it,
525 const array_1d<double,4>&
N,
527 Variable<array_1d<double,3> >& rOriginVariable,
528 Variable<array_1d<double,3> >& rDestinationVariable)
533 Geometry< Node >& geom = el_it->GetGeometry();
540 const array_1d<double,3>& step_data = (pnode)->FastGetSolutionStepValue(rDestinationVariable, 0);
541 array_1d<double,3>& node0_data = geom[0].FastGetSolutionStepValue(rOriginVariable, 0);
542 array_1d<double,3>& node1_data = geom[1].FastGetSolutionStepValue(rOriginVariable, 0);
543 array_1d<double,3>& node2_data = geom[2].FastGetSolutionStepValue(rOriginVariable, 0);
544 array_1d<double,3>& node3_data = geom[3].FastGetSolutionStepValue(rOriginVariable, 0);
547 for (
unsigned int j= 0;
j< TDim;
j++)
549 origin_data = step_data[
j];
550 node0_data[
j] += -
N[0] * origin_data;
551 node1_data[
j] += -
N[1] * origin_data;
552 node2_data[
j] += -
N[2] * origin_data;
553 node3_data[
j] += -
N[3] * origin_data;
559 inline void Clear(ModelPart::NodesContainerType::iterator node_it,
int step_data_size )
561 unsigned int buffer_size = node_it->GetBufferSize();
566 double* step_data = (node_it)->SolutionStepData().Data(
step);
569 for (
int j= 0;
j< step_data_size;
j++)
577 inline void ClearVariables(ModelPart::NodesContainerType::iterator node_it , Variable<array_1d<double,3> >& rVariable)
579 array_1d<double, 3>& Aux_var = node_it->FastGetSolutionStepValue(rVariable, 0);
586 inline void ClearVariables(ModelPart::NodesContainerType::iterator node_it, Variable<double>& rVariable)
588 double& Aux_var = node_it->FastGetSolutionStepValue(rVariable, 0);
642 template<std::
size_t TDim>
647 rOStream << std::endl;
This class is designed to allow the fast location of MANY points on the top of a 3D mesh.
Definition: binbased_fast_point_locator.h:68
Geometry base class.
Definition: geometry.h:71
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int step
Definition: face_heat.py:88
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
R
Definition: isotropic_damage_automatic_differentiation.py:172
int j
Definition: quadrature.py:648
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
N
Definition: sensitivityMatrix.py:29