Arcane  4.1.15.0
User documentation
Loading...
Searching...
No Matches
PoissonModule.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2#include "PoissonModule.h"
3
4#include <arcane/MathUtils.h>
5#include <arcane/IParallelMng.h>
6#include <arcane/ITimeLoopMng.h>
7
8using namespace Arcane;
9
10/*---------------------------------------------------------------------------*/
11/*---------------------------------------------------------------------------*/
12
14{
15 // so that the extractions do not overlap
16 m_global_deltat = 1;
17
18 // initialization of temperature on all cells
19 // ...
20
21 // application of temperature at the boundaries
22 applyBoundaryConditions();
23}
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
29{
30 Real max_delta_cell_t = 0;
31
32 // update of temperature on cells
33 // ...
34 {
35 // calculation of the new temperature
36 // ...
37 // new_cell_t
38 // ...
39
40 // we observe the difference
41 Real delta_cell_t = math::abs(new_cell_t - m_cell_temperature[icell]);
42 max_delta_cell_t = math::max(max_delta_cell_t, delta_cell_t);
43
44 // update of temperature
45 m_cell_temperature[icell] = new_cell_t;
46 }
47
48 // update of temperature at nodes
49 // ...
50
51 // Given the calculation, synchronization of temperature on cells is unnecessary
52 // synchronization of temperature at nodes and reduction of the difference
53 // ...
54
55 // application of boundary conditions
56 applyBoundaryConditions();
57
58 // test for stopping the time loop
59 if (max_delta_cell_t < 0.2) subDomain()->timeLoopMng()->stopComputeLoop(true);
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65void PoissonModule::applyBoundaryConditions()
66{
67 // loop over boundary conditions
68 int nb_boundary_condition = options()->boundaryCondition.size();
69 for (int i = 0; i < nb_boundary_condition; ++i)
70 {
71 FaceGroup face_group = options()->boundaryCondition[i]->surface();
72 Real temperature = options()->boundaryCondition[i]->value();
73 TypesPoisson::eBoundaryCondition type = options()->boundaryCondition[i]->type();
74
75 // loop over faces of the surface
76 ENUMERATE_FACE(iface, face_group)
77 {
78 const Face & face = * iface;
79 Integer nb_node = face.nbNode();
80
81 // loop over nodes of the face
82 for (NodeEnumerator inode(face.nodes()); inode(); ++inode)
83 {
84 switch (type)
85 {
86 case TypesPoisson::Temperature:
87 m_node_temperature[inode] = temperature;
88 break;
89 case TypesPoisson::Unknown:
90 break;
91 }
92 }
93 }
94 }
95}
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100ARCANE_REGISTER_MODULE_POISSON(PoissonModule);
#define ENUMERATE_FACE(name, group)
Generic enumerator for a face group.
Face of a cell.
Definition Item.h:1032
NodeConnectedListViewType nodes() const
List of nodes of the entity.
Definition Item.h:843
Int32 nbNode() const
Number of nodes of the entity.
Definition Item.h:837
virtual void initTemperatures()
virtual void propagateTemperatures()
ItemGroupT< Face > FaceGroup
Group of faces.
Definition ItemTypes.h:179
ItemEnumeratorT< Node > NodeEnumerator
Enumerators over nodes.
Definition ItemTypes.h:255
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.