10 #if !defined(KRATOS_MESH_ERROR_CALCULATION_UTILITIES_H_INCLUDED)
11 #define KRATOS_MESH_ERROR_CALCULATION_UTILITIES_H_INCLUDED
86 std::vector<double> ElementalError;
87 std::vector<int> elems_ids;
91 if (!rNodalError.size())
94 std::fill(rNodalError.begin(), rNodalError.end(), 100);
99 std::fill(rIds.begin(), rIds.end(), 0);
101 double NodalMeanError = 0;
104 for (
auto &i_node : rModelPart.
Nodes())
106 if (i_node.IsNot(NEW_ENTITY))
112 for (
auto &i_nelem : nElements)
114 NodalMeanError += ElementalError[elems_ids[i_nelem.Id()]];
117 rIds[i_node.Id()] = id;
118 rNodalError[id] = NodalMeanError /
double(nElements.
size());
123 rIds[i_node.Id()] = id;
143 std::fill(ElementVariable.begin(), ElementVariable.end(), 0);
145 std::vector<int> elems_ids;
147 std::fill(elems_ids.begin(), elems_ids.end(), 0);
152 std::vector<double> Value(1);
155 for (ModelPart::ElementsContainerType::const_iterator ie = rModelPart.
ElementsBegin(); ie != rModelPart.
ElementsEnd(); ++ie)
159 elems_ids[ie->Id()] = id;
160 ElementVariable[id] = Value[0];
162 if (ElementVariable[
id] > VariableMax)
163 VariableMax = ElementVariable[id];
165 if (ElementVariable[
id] < VariableMin)
166 VariableMin = ElementVariable[id];
174 std::vector<double> NodalError(rModelPart.
NumberOfNodes() + 1);
175 std::fill(NodalError.begin(), NodalError.end(), 0);
178 std::fill(nodes_ids.begin(), nodes_ids.end(), 0);
180 double PatchSize = 0;
181 double PatchError = 0;
187 for (
auto &i_node : rModelPart.
Nodes())
190 if (i_node.IsNot(NEW_ENTITY))
198 for (
auto &i_nelem : nElements)
204 Error = ElementVariable[elems_ids[i_nelem.Id()]] *
Size;
212 nodes_ids[i_node.Id()] = id;
213 NodalError[id] = PatchError / PatchSize;
218 std::cout <<
" WARNING : Size surrounding node: " << i_node.Id() <<
" is null " << std::endl;
223 nodes_ids[i_node.Id()] = id;
231 std::fill(rElementalError.begin(), rElementalError.end(), 100);
234 std::fill(rIds.begin(), rIds.end(), 0);
236 double VariableVariation = VariableMax - VariableMin;
238 if (VariableVariation == 0)
240 VariableVariation = 1;
241 std::cout <<
" WARNING: " << rVariable <<
" min-max errors are the same ( MinVar= " << VariableMin <<
", MaxVar= " << VariableMax <<
" )" << std::endl;
247 std::cout <<
" Variable errors ( MinVar= " << VariableMin <<
", MaxVar= " << VariableMax <<
" )" << std::endl;
250 for (
auto &i_elem : rModelPart.
Elements())
256 unsigned int NumberOfVertices = vertices.size();
257 for (
unsigned int i = 0;
i < NumberOfVertices; ++
i)
259 PatchError += NodalError[nodes_ids[vertices[
i].Id()]];
262 if (NumberOfVertices != 0)
264 PatchError /=
double(NumberOfVertices);
268 std::cout <<
" ERROR ME: Number of Vertices of the Element: " << i_elem.Id() <<
" is null " << std::endl;
271 rIds[i_elem.Id()] = id;
272 rElementalError[id] = fabs((PatchError - ElementVariable[
id]) / VariableVariation) * 100;
Geometry base class.
Definition: geometry.h:71
PointerVector< TPointType > PointsArrayType
Definition: geometry.h:118
virtual double DomainSize() const
This method calculate and return length, area or volume of this geometry depending to it's dimension.
Definition: geometry.h:1371
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
size_type size() const
Definition: global_pointers_vector.h:307
Short class definition.
Definition: mesh_error_calculation_utilities.hpp:50
ModelPart::NodesContainerType NodesContainerType
Definition: mesh_error_calculation_utilities.hpp:55
void NodalErrorCalculation(ModelPart &rModelPart, std::vector< double > &rNodalError, std::vector< int > &rIds, const Variable< double > &rVariable)
Definition: mesh_error_calculation_utilities.hpp:82
int GetEchoLevel()
Definition: mesh_error_calculation_utilities.hpp:289
void ElementalErrorCalculation(ModelPart &rModelPart, std::vector< double > &rElementalError, std::vector< int > &rIds, const Variable< double > &rVariable)
Definition: mesh_error_calculation_utilities.hpp:136
virtual void SetEchoLevel(int Level)
Definition: mesh_error_calculation_utilities.hpp:284
~MeshErrorCalculationUtilities()
Destructor.
Definition: mesh_error_calculation_utilities.hpp:69
MeshErrorCalculationUtilities()
Default constructor.
Definition: mesh_error_calculation_utilities.hpp:66
ModelPart::ElementsContainerType ElementsContainerType
Definition: mesh_error_calculation_utilities.hpp:54
ModelPart::MeshType::GeometryType::PointsArrayType PointsArrayType
Definition: mesh_error_calculation_utilities.hpp:56
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: mesh_error_calculation_utilities.hpp:59
GlobalPointersVector< Condition > ConditionWeakPtrVectorType
Definition: mesh_error_calculation_utilities.hpp:60
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: mesh_error_calculation_utilities.hpp:58
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1408
static unsigned int GetMaxElementId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1481
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
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static double max(double a, double b)
Definition: GeometryFunctions.h:79
static double min(double a, double b)
Definition: GeometryFunctions.h:71
pybind11::list CalculateOnIntegrationPoints(TObject &dummy, const Variable< TDataType > &rVariable, const ProcessInfo &rProcessInfo)
Definition: add_mesh_to_python.cpp:142
TSpaceType::IndexType Size(TSpaceType &dummy, typename TSpaceType::VectorType const &rV)
Definition: add_strategies_to_python.cpp:111
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
integer i
Definition: TensorModule.f:17