KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
nist_utilities.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3 KratosULFApplication
4 A library based on:
5 Kratos
6 A General Purpose Software for Multi-Physics Finite Element Analysis
7 Version 1.0 (Released on march 05, 2007).
8 
9 Copyright 2007
10 Pooyan Dadvand, Riccardo Rossi
11 pooyan@cimne.upc.edu
12 rrossi@cimne.upc.edu
13 - CIMNE (International Center for Numerical Methods in Engineering),
14 Gran Capita' s/n, 08034 Barcelona, Spain
15 
16 
17 Permission is hereby granted, free of charge, to any person obtaining
18 a copy of this software and associated documentation files (the
19 "Software"), to deal in the Software without restriction, including
20 without limitation the rights to use, copy, modify, merge, publish,
21 distribute, sublicense and/or sell copies of the Software, and to
22 permit persons to whom the Software is furnished to do so, subject to
23 the following condition:
24 
25 Distribution of this code for any commercial purpose is permissible
26 ONLY BY DIRECT ARRANGEMENT WITH THE COPYRIGHT OWNERS.
27 
28 The above copyright notice and this permission notice shall be
29 included in all copies or substantial portions of the Software.
30 
31 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
35 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 
39 ==============================================================================
40 */
41 
42 //
43 // Project Name: Kratos
44 // Last Modified by: $Author: rrossi $
45 // Date: $Date: 2007-03-07 15:44:25 $
46 // Revision: $Revision: 1.1 $
47 //
48 //
49 
50 
51 #if !defined(KRATOS_NIST_UTILITIES_INCLUDED )
52 #define KRATOS_NIST_UTILITIES_INCLUDED
53 
54 
55 
56 // System includes
57 #include <string>
58 #include <iostream>
59 #include <algorithm>
60 
61 // External includes
62 
63 
64 // Project includes
65 #include <pybind11/pybind11.h>
66 #include "includes/define.h"
67 #include "includes/define_python.h"
68 
69 #include "includes/model_part.h"
70 #include "includes/node.h"
71 #include "utilities/geometry_utilities.h"
73 #include "ULF_application.h"
74 
75 namespace Kratos
76 {
77 class NistUtils
78 {
79 public:
80 
81 
82  //**********************************************************************************************
83  //**********************************************************************************************
85  ModelPart& OriginModelPart ,
86  ModelPart& DestinationModelPart,
87  Element const& rReferenceElement,
88  Condition const& rReferenceBoundaryCondition
89  )
90  {
91  KRATOS_TRY;
92 
93  //assigning the nodes to the new model part
94  DestinationModelPart.Nodes().clear();
95  DestinationModelPart.Nodes() = OriginModelPart.Nodes();
96 
97  //generating the elements
98  int id = 1;
99  Properties::Pointer properties = OriginModelPart.GetMesh().pGetProperties(1);
100  for(ModelPart::ElementsContainerType::iterator iii = OriginModelPart.ElementsBegin(); iii != OriginModelPart.ElementsEnd(); iii++)
101  {
102  Geometry< Node >& geom = iii->GetGeometry();
103  Element::Pointer p_element = rReferenceElement.Create(id, geom ,properties);
104  DestinationModelPart.Elements().push_back(p_element);
105  id = id + 1;
106  }
107  std::cout << "Elements are generated" << std::endl;
108 
109  //generating the conditions
110  id = 1;
111  for(ModelPart::ConditionsContainerType::iterator iii = OriginModelPart.ConditionsBegin(); iii != OriginModelPart.ConditionsEnd(); iii++)
112  {
113  Geometry< Node >& geom = iii->GetGeometry();
114  double nfree_surf = 0;
115  for(unsigned int k = 0; k<geom.size(); k++)
116  nfree_surf += geom[k].FastGetSolutionStepValue(IS_FREE_SURFACE);
117 
118  if(nfree_surf > 1)
119  {
120  Condition::Pointer p_condition = rReferenceBoundaryCondition.Create(id, geom,properties);
121  DestinationModelPart.Conditions().push_back(p_condition);
122  id = id + 1;
123  }
124  }
125  std::cout << "Conditions are generated" << std::endl;
126 
127  KRATOS_CATCH("");
128  }
129 
130 
131  //**********************************************************************************************
132  //**********************************************************************************************
134  ModelPart& ThisModelPart ,
135  double wall_temperature
136  )
137  {
138  KRATOS_TRY;
139  for(ModelPart::NodesContainerType::iterator in = ThisModelPart.NodesBegin();
140  in!=ThisModelPart.NodesEnd(); in++)
141  {
142  if(in->FastGetSolutionStepValue(IS_STRUCTURE) == 1 &&
143  (in->GetValue(NEIGHBOUR_ELEMENTS)).size() == 0 )
144  {
145  in->FastGetSolutionStepValue(TEMPERATURE) = wall_temperature;
146  }
147  }
148 
149  KRATOS_CATCH("");
150  }
151 
152  //**********************************************************************************************
153  //**********************************************************************************************
156  )
157  {
158  KRATOS_TRY;
159 
160  double level = 0.00;
161  for(ModelPart::NodesContainerType::iterator in = nodes.begin();
162  in!=nodes.end(); in++)
163  {
164  if( (in->GetValue(NEIGHBOUR_ELEMENTS)).size() != 0 )
165  {
166  if( in->Y() > level) level = in->Y();
167  }
168  }
169  return level;
170 
171  KRATOS_CATCH("");
172  }
173 
174 private:
175 
176 };
177 
178 } // namespace Kratos.
179 
180 #endif // KRATOS_NIST_UTILITIES_INCLUDED defined
181 
182 
Base class for all Conditions.
Definition: condition.h:59
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new condition pointer.
Definition: condition.h:205
Base class for all Elements.
Definition: element.h:60
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new element pointer.
Definition: element.h:202
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
PropertiesType::Pointer pGetProperties(IndexType PropertiesId)
Definition: mesh.h:394
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
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
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
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
Definition: nist_utilities.h:78
double FindFluidLevel(ModelPart::NodesContainerType nodes)
Definition: nist_utilities.h:154
void ApplyInitialTemperature(ModelPart &ThisModelPart, double wall_temperature)
Definition: nist_utilities.h:133
void GenerateModelPart(ModelPart &OriginModelPart, ModelPart &DestinationModelPart, Element const &rReferenceElement, Condition const &rReferenceBoundaryCondition)
Definition: nist_utilities.h:84
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
int k
Definition: quadrature.py:595