12 #if !defined(KRATOS_BFECC_LIMITER_CONVECTION_INCLUDED )
13 #define KRATOS_BFECC_LIMITER_CONVECTION_INCLUDED
15 #define PRESSURE_ON_EULERIAN_MESH
16 #define USE_FEW_PARTICLES
32 #include "utilities/geometry_utilities.h"
49 : mpSearchStructure(pSearchStructure)
66 const int max_results = 10000;
69 const int nparticles = rModelPart.
Nodes().size();
72 std::vector< Vector > Ns( rModelPart.
Nodes().size());
73 std::vector< bool > found( rModelPart.
Nodes().size());
74 std::vector< bool > foundf( rModelPart.
Nodes().size());
77 for (
auto &r_node : rModelPart.
Nodes()) {
78 r_node.SetValue(rVar, 0.0);
79 r_node.SetValue(BFECC_ERROR, 0.0);
80 r_node.SetValue(BFECC_ERROR_1, 0.0);
84 #pragma omp parallel for firstprivate(results,N)
85 for (
int i = 0;
i < nparticles;
i++)
89 ModelPart::NodesContainerType::iterator iparticle = rModelPart.
NodesBegin() +
i;
91 Element::Pointer pelement;
99 elem_backward(
i) = pelement;
103 double phi1 =
N[0] * ( geom[0].FastGetSolutionStepValue(rVar,1));
104 for (
unsigned int k = 1;
k < geom.
size();
k++) {
105 phi1 +=
N[
k] * ( geom[
k].FastGetSolutionStepValue(rVar,1) );
108 iparticle->FastGetSolutionStepValue(rVar) = phi1;
113 #pragma omp parallel for firstprivate(results,N)
114 for (
int i = 0;
i < nparticles;
i++)
118 ModelPart::NodesContainerType::iterator iparticle = rModelPart.
NodesBegin() +
i;
120 Element::Pointer pelement;
124 foundf[
i] = is_found;
128 double phi_old =
N[0] * ( geom[0].FastGetSolutionStepValue(rVar));
130 for (
unsigned int k = 1;
k < geom.
size();
k++) {
131 phi_old +=
N[
k] * ( geom[
k].FastGetSolutionStepValue(rVar) );
135 iparticle->GetValue(BFECC_ERROR_1) = 0.5*iparticle->FastGetSolutionStepValue(rVar,1) - 0.5*
phi_old;
136 iparticle->GetValue(rVar) = iparticle->FastGetSolutionStepValue(rVar,1) + iparticle->GetValue(BFECC_ERROR_1);
140 #pragma omp parallel for
141 for (
int i = 0;
i < nparticles;
i++)
143 ModelPart::NodesContainerType::iterator iparticle = rModelPart.
NodesBegin() +
i;
144 bool is_found = found[
i];
148 double phi1 =
N[0] * ( geom[0].
GetValue(rVar));
149 for (
unsigned int k = 1;
k < geom.
size();
k++) {
152 iparticle->FastGetSolutionStepValue(rVar) = phi1;
162 for(
int i = 0 ;
i < nelements;
i++)
166 ModelPart::ElementsContainerType::iterator i_element = rModelPart.
ElementsBegin() +
i;
169 Element::Pointer pelement;
173 for(
unsigned int j = 0 ;
j < element_geometry.
size();
j++){
174 for(
int k = 0 ;
k < 3;
k++){
175 vel[
k] += element_geometry[
j].GetSolutionStepValue(conv_var)[
k] / element_geometry.
size();
182 for(
unsigned int j = 0 ;
j < element_geometry.
size();
j++){
183 e1 += element_geometry[
j].
GetValue(BFECC_ERROR_1);
185 e1 /= element_geometry.
size();
191 double phi2 =
N[0] * ( geom[0].FastGetSolutionStepValue(rVar));
192 for (
unsigned int k = 1;
k < geom.
size();
k++) {
193 phi2 +=
N[
k] * ( geom[
k].FastGetSolutionStepValue(rVar) );
195 double solution_in_center = 0;
197 for(
unsigned int j = 0 ;
j < element_geometry.
size();
j++){
198 solution_in_center += i_element->GetGeometry()[
j].FastGetSolutionStepValue(rVar,1);
200 solution_in_center /= element_geometry.
size();
202 e2 = solution_in_center - (phi2 + e1);
204 if(std::abs(e2) > std::abs(e1)){
205 for(
unsigned int j = 0 ;
j < element_geometry.
size();
j++){
213 #pragma omp parallel for
214 for (
int i = 0;
i < nparticles;
i++){
215 ModelPart::NodesContainerType::iterator iparticle = rModelPart.
NodesBegin() +
i;
216 bool is_found = foundf[
i];
218 iparticle->GetValue(rVar) = iparticle->FastGetSolutionStepValue(rVar,1) + iparticle->GetValue(BFECC_ERROR);
222 #pragma omp parallel for
223 for (
int i = 0;
i < nparticles;
i++){
224 ModelPart::NodesContainerType::iterator iparticle = rModelPart.
NodesBegin() +
i;
225 bool is_found = found[
i];
229 double phi1 =
N[0] * ( geom[0].
GetValue(rVar));
230 for (
unsigned int k = 1;
k < geom.
size();
k++) {
233 iparticle->FastGetSolutionStepValue(rVar) = phi1;
242 if(
x > 0.0f &&
y > 0.0f)
244 else if(
x < 0.0f &&
y < 0.0f)
256 Element::Pointer& pelement,
258 const unsigned int max_results,
259 const double velocity_sign,
260 const double subdivisions)
262 bool is_found =
false;
264 const double small_dt =
dt/subdivisions;
267 if(velocity_sign > 0.0)
269 noalias(position) += small_dt*initial_velocity;
270 unsigned int substep=0;
271 while(substep++ < subdivisions)
273 is_found = mpSearchStructure->FindPointOnMesh(position,
N, pelement, result_begin, max_results);
275 if (is_found ==
true)
279 const double new_step_factor =
static_cast<double>(substep)/subdivisions;
280 const double old_step_factor = (1.0 - new_step_factor);
282 noalias(veulerian) =
N[0] * ( new_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY,1));
283 for (
unsigned int k = 1;
k < geom.
size();
k++)
284 noalias(veulerian) +=
N[
k] * ( new_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY,1) );
286 noalias(position) += small_dt*veulerian;
296 noalias(position) -= small_dt*initial_velocity;
297 unsigned int substep=0;
298 while(substep++ < subdivisions)
300 is_found = mpSearchStructure->FindPointOnMesh(position,
N, pelement, result_begin, max_results);
302 if (is_found ==
true)
307 const double old_step_factor =
static_cast<double>(substep)/subdivisions;
308 const double new_step_factor = (1.0 - old_step_factor);
310 noalias(veulerian) =
N[0] * ( new_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY,1));
311 for (
unsigned int k = 1;
k < geom.
size();
k++)
312 noalias(veulerian) +=
N[
k] * ( new_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY,1) );
314 noalias(position) -= small_dt*veulerian;
Definition: bfecc_elemental_limiter_convection.h:44
KRATOS_CLASS_POINTER_DEFINITION(BFECCLimiterConvection< TDim >)
BFECCLimiterConvection(typename BinBasedFastPointLocator< TDim >::Pointer pSearchStructure)
Definition: bfecc_elemental_limiter_convection.h:48
bool ConvectBySubstepping(const double dt, array_1d< double, 3 > &position, const array_1d< double, 3 > &initial_velocity, Vector &N, Element::Pointer &pelement, typename BinBasedFastPointLocator< TDim >::ResultIteratorType &result_begin, const unsigned int max_results, const double velocity_sign, const double subdivisions)
Definition: bfecc_elemental_limiter_convection.h:251
void BFECCconvect(ModelPart &rModelPart, const Variable< double > &rVar, const Variable< array_1d< double, 3 > > &conv_var, const double substeps)
Definition: bfecc_elemental_limiter_convection.h:59
~BFECCLimiterConvection()
Definition: bfecc_elemental_limiter_convection.h:53
double minmod(double x, double y)
Definition: bfecc_elemental_limiter_convection.h:240
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
ConfigureType::ResultIteratorType ResultIteratorType
Definition: binbased_fast_point_locator.h:82
ConfigureType::ResultContainerType ResultContainerType
Definition: binbased_fast_point_locator.h:81
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
SizeType NumberOfElements(IndexType ThisIndex=0) const
Definition: model_part.h:1027
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
dt
Definition: DEM_benchmarks.py:173
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
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
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
phi_old
Definition: generate_convection_diffusion_explicit_element.py:103
f
Definition: generate_convection_diffusion_explicit_element.py:112
vel
Definition: pure_conduction.py:76
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17