15 #if !defined(KRATOS_UPDATE_CONDITIONS_ON_FREE_SURFACE_PROCESS_H_INCLUDED)
16 #define KRATOS_UPDATE_CONDITIONS_ON_FREE_SURFACE_PROCESS_H_INCLUDED
58 "update_conditions" : true,
59 "sub_model_part_list" : [],
60 "reference_condition_list" : []
67 if (rParameters[
"sub_model_part_list"].size() != rParameters[
"reference_condition_list"].size()) {
68 KRATOS_ERROR <<
" sub_model_part_list and reference_condition_list must have the same dimension " << std::endl;
71 for (
unsigned int i = 0;
i < rParameters[
"sub_model_part_list"].
size();
i++) {
72 mListOfSubModelParts.push_back(rParameters[
"sub_model_part_list"][
i].GetString());
73 mListOfReferenceConditions.push_back(rParameters[
"reference_condition_list"][
i].GetString());
101 this->ClearAllConditions();
102 this->UpdateConditionsAfterRemesh();
134 std::vector<std::string> mListOfSubModelParts;
135 std::vector<std::string> mListOfReferenceConditions;
136 std::size_t mEchoLevel;
146 void UpdateConditionsAfterRemesh()
const {
151 std::string computing_model_part_name;
153 if ((i_mp->Is(ACTIVE) && i_mp->Is(SOLID)) || (i_mp->Is(ACTIVE) && i_mp->Is(FLUID))) {
154 computing_model_part_name = i_mp->Name();
157 ModelPart& r_computing_model_part = mrModelPart.GetSubModelPart(computing_model_part_name);
160 unsigned int condition_id = r_computing_model_part.NumberOfConditions();
163 for (
unsigned int i = 0;
i < mListOfSubModelParts.size();
i++)
166 ModelPart& r_sub_model_part = mrModelPart.GetSubModelPart(mListOfSubModelParts[
i]);
169 VariableUtils().SetFlag(TO_ERASE,
true, r_sub_model_part.Nodes());
170 r_sub_model_part.RemoveNodes(TO_ERASE);
171 VariableUtils().SetFlag(TO_ERASE,
false, mrModelPart.Nodes());
177 Properties::Pointer p_property = mrModelPart.GetParentModelPart().pGetProperties(0);
178 for (
auto i_prop(r_sub_model_part.PropertiesBegin()); i_prop != r_sub_model_part.PropertiesEnd(); ++i_prop) {
179 if (!i_prop->IsEmpty()) {
180 const int prop_id = i_prop->Id();
181 p_property = r_sub_model_part.GetParentModelPart().pGetProperties(prop_id);
188 BuiltinTimer time_elapsed;
191 for (
auto i_elem(r_computing_model_part.ElementsBegin()); i_elem != r_computing_model_part.ElementsEnd(); ++i_elem)
193 Geometry<Node>& r_geometry = i_elem->GetGeometry();
194 DenseMatrix<unsigned int> lpofa;
195 DenseVector<unsigned int> lnofa;
196 r_geometry.NodesInFaces(lpofa);
197 r_geometry.NumberNodesInFaces(lnofa);
201 unsigned int iface = 0;
202 for (
auto& i_nelem : number_of_neighbour_elements)
204 unsigned int number_of_nodes_in_face = lnofa[iface];
206 if (i_nelem.Id() == i_elem->Id())
210 face_nodes.
reserve(number_of_nodes_in_face);
211 unsigned int number_of_rigid_nodes = 0;
212 for (
unsigned int j = 1;
j <= number_of_nodes_in_face; ++
j) {
213 face_nodes.push_back(r_geometry(lpofa(
j, iface)));
214 if (face_nodes[
j - 1].
Is(RIGID)) {
215 number_of_rigid_nodes += 1;
220 if (number_of_rigid_nodes != number_of_nodes_in_face)
223 Condition::Pointer p_condition = r_reference_condition.Create(condition_id++, face_nodes, p_property);
224 mrModelPart.Conditions().push_back(p_condition);
225 r_sub_model_part.Conditions().push_back(p_condition);
228 for (
unsigned int j = 1;
j <= number_of_nodes_in_face; ++
j) {
230 for (
auto i_node(r_sub_model_part.NodesBegin()); i_node != r_sub_model_part.NodesEnd(); ++i_node)
231 if (i_node->Id() == r_geometry(lpofa(
j, iface))->Id())
234 r_sub_model_part.Nodes().push_back(r_geometry(lpofa(
j, iface)));
241 KRATOS_INFO_IF(
"UpdateConditionsAfterRemeshProcess ", mEchoLevel > 0)
242 <<
" SubModelPart: " << mListOfSubModelParts[
i] <<
" Rebuild time: " << time_elapsed.ElapsedSeconds() << std::endl;
248 BuiltinTimer time_elapsed;
251 ModelPart& r_origin_part = mrModelPart.GetSubModelPart(mListOfSubModelParts[0]);
254 r_sub_model_part.AddNodes(r_origin_part.NodesBegin(), r_origin_part.NodesEnd());
258 temp_conditions.
reserve(r_origin_part.NumberOfConditions());
261 for (
auto i_cond = r_origin_part.ConditionsBegin(); i_cond != r_origin_part.ConditionsEnd(); ++i_cond)
264 Condition::Pointer p_condition = r_reference_condition.Create(condition_id++, i_cond->pGetGeometry(), p_property);
265 temp_conditions.push_back(p_condition);
269 r_sub_model_part.AddConditions(temp_conditions.begin(), temp_conditions.end());
270 mrModelPart.AddConditions(temp_conditions.begin(), temp_conditions.end());
272 KRATOS_INFO_IF(
"UpdateConditionsAfterRemeshProcess ", mEchoLevel > 0)
273 <<
" SubModelPart: " << mListOfSubModelParts[
i] <<
" Rebuild time: " << time_elapsed.ElapsedSeconds() << std::endl;
279 void ClearAllConditions()
const {
281 for (
unsigned int i = 0;
i < mListOfSubModelParts.size();
i++)
283 ModelPart& r_sub_model_part = mrModelPart.GetSubModelPart(mListOfSubModelParts[
i]);
284 VariableUtils().SetFlag(TO_ERASE,
true, r_sub_model_part.Conditions());
285 r_sub_model_part.RemoveConditionsFromAllLevels(TO_ERASE);
328 rOStream << std::endl;
Geometry< NodeType >::PointsArrayType NodesArrayType
definition of nodes container type, redefined from GeometryType
Definition: condition.h:86
bool Is(Flags const &rOther) const
Definition: flags.h:274
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
SizeType size() const
This method returns the total size of the current array parameter.
Definition: kratos_parameters.cpp:993
void reserve(size_type dim)
Definition: pointer_vector.h:319
void reserve(int reservedsize)
Reserves memory for a specified number of elements.
Definition: pointer_vector_set.h:733
The base class for all processes in Kratos.
Definition: process.h:49
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: process.h:204
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: process.h:210
This process updates the conditions applied to the free surface after the remeshing.
Definition: update_conditions_on_free_surface_process.hpp:39
KRATOS_CLASS_POINTER_DEFINITION(UpdateConditionsOnFreeSurfaceProcess)
virtual ~UpdateConditionsOnFreeSurfaceProcess()
Destructor.
Definition: update_conditions_on_free_surface_process.hpp:83
UpdateConditionsOnFreeSurfaceProcess(ModelPart &rModelPart, Parameters rParameters)
Default constructor.
Definition: update_conditions_on_free_surface_process.hpp:51
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: update_conditions_on_free_surface_process.hpp:90
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: update_conditions_on_free_surface_process.hpp:97
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: build_model_part_boundary_process.hpp:60
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_INFO_IF(label, conditional)
Definition: logger.h:251
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17