7#include "arcane/aleph/tests/AlephTest.h"
8#include "arcane/aleph/tests/AlephTestScheme.h"
9#include "arcane/aleph/tests/AlephTestSchemeFaces.h"
11#include "arcane/mesh/CellFamily.h"
12#include "arcane/mesh/FaceFamily.h"
23using namespace Arcane;
32: ArcaneAlephTestSchemeFacesObject(sbi)
34 debug() <<
"\33[37m\t[AlephTestSchemeFaces::AlephTestSchemeFaces] New"
38AlephTestSchemeFaces::~AlephTestSchemeFaces(
void)
40 debug() <<
"\33[37m\t[AlephTestSchemeFaces::AlephTestSchemeFaces] Delete"
47void AlephTestSchemeFaces::
50 ItacFunction(AlephTestSchemeFaces);
52 for (
int i = module_options->boundaryCondition.size() - 1; i >= 0; --i) {
53 Real temperature = module_options->boundaryCondition[i]->value();
54 FaceGroup face_group = module_options->boundaryCondition[i]->surface();
57 m_face_temperature[iFace] = temperature;
65void AlephTestSchemeFaces::
66preFetchNumElementsForEachRow(
IntegerArray& rows_nb_element,
69 ItacFunction(AlephTestSchemeFaces);
70 debug() <<
"\33[37m\t[AlephTestSchemeFaces::preFetchNumElementsForEachRow]"
73 rows_nb_element.
fill(1);
78 if (iFace->backCell().isOwn())
79 rows_nb_element[m_cell_matrix_idx[iFace->backCell()] - rank_row_offset] += 1;
80 if (iFace->frontCell().isOwn())
81 rows_nb_element[m_cell_matrix_idx[iFace->frontCell()] - rank_row_offset] += 1;
88void AlephTestSchemeFaces::
93 m_cell_coefs[iCell] = 0.;
95 debug() <<
"\33[37m[AlephTestSchemeFaces::setValues] inner-faces"
98 if (iFace->backCell().isOwn()) {
99 const Real surface = AlephTestModule::geoFaceSurface(*iFace, nodesCoordinates());
100 aleph_mat->setValue(m_cell_matrix_idx[iFace->backCell()],
101 m_cell_matrix_idx[iFace->frontCell()], -deltaT / surface);
102 m_cell_coefs[iFace->backCell()] += 1.0 / surface;
104 if (iFace->frontCell().isOwn()) {
105 const Real surface = AlephTestModule::geoFaceSurface(*iFace, nodesCoordinates());
106 aleph_mat->setValue(m_cell_matrix_idx[iFace->frontCell()],
107 m_cell_matrix_idx[iFace->backCell()], -deltaT / surface);
108 m_cell_coefs[iFace->frontCell()] += 1.0 / surface;
111 debug() <<
"\33[37m[AlephTestSchemeFaces::setValues] outer-faces"
114 if (!iFace->cell(0).isOwn())
116 m_cell_coefs[iFace->cell(0)] += 1.0 / AlephTestModule::geoFaceSurface(*iFace, nodesCoordinates());
118 debug() <<
"\33[37m[AlephTestSchemeFaces::setValues] diagonale"
121 aleph_mat->
setValue(m_cell_matrix_idx[iCell], m_cell_matrix_idx[iCell], 1.0 + deltaT * m_cell_coefs[iCell]);
123 debug() <<
"\33[37m[AlephTestSchemeFaces::setValues] done"
130bool AlephTestSchemeFaces::
131amrRefine(
RealArray& values,
const Real trigRefine)
133 ItacFunction(AlephTestSchemeFaces);
136 debug() <<
"\33[37m[AlephTestModule::_FaceAmrRefine]"
148 if ((*iCell).level() == 1)
150 const Real T0 = m_cell_temperature[iCell];
151 const Real T1 = values[m_cell_matrix_idx[iCell]];
152 const Real ecart_relatif = ECART_RELATIF(T0, T1);
153 Cell iItem = (*iCell);
155 if (ecart_relatif > trigRefine) {
157 cells_lid.
add((*iCell).localId());
162 if (cells_lid.
size() == 0)
165 debug() <<
"\33[37m[AlephTestModule::_amrRefine] NOW refine"
167 MESH_MODIFIER_REFINE_ITEMS(
mesh());
168 mesh()->modifier()->endUpdate();
173 for (
Integer i = 0, is = cells_lid.
size(); i < is; ++i) {
174 Int32 lid = cells_lid[i];
175 Cell cell = cells[lid];
177 for (
Integer j = 0, js = CELL_NB_H_CHILDREN(cell); j < js; ++j) {
179 m_cell_temperature[cells[CELL_H_CHILD(cell, j).localId()]] = m_cell_temperature[cells[lid]];
180 auto faces = allCells().view()[CELL_H_CHILD(cell, j).localId()].toCell().faces();
182 for (
Face face : faces) {
183 if (face.isSubDomainBoundary()) {
185 m_face_temperature[face] = m_face_temperature[cell.
face(index)];
189 m_face_temperature[face] = 0;
196 debug() <<
"\33[37m[AlephTestModule::_amrRefine] done"
204bool AlephTestSchemeFaces::
205amrCoarsen(
RealArray& values,
const Real trigCoarsen)
207 ItacFunction(AlephTestSchemeFaces);
210 debug() <<
"\33[37m[AlephTestModule::_FaceAmrCoarsen]"
230 if (cell.
level() == 1)
233 if (!CELL_HAS_H_CHILDREN(cell))
237 for (
Integer j = 0, js = CELL_NB_H_CHILDREN(cell); j < js; ++j)
238 coarsit &= CELL_H_CHILD(cell, j).
isActive();
239 if (coarsit ==
false)
243 for (
Integer j = 0, js = CELL_NB_H_CHILDREN(cell); j < js; ++j) {
244 oldTs[j] = m_cell_temperature[cells[CELL_H_CHILD(cell, j).localId()]];
245 newTs[j] = values[m_cell_matrix_idx[CELL_H_CHILD(cell, j)]];
247 coarsit &= (ECART_RELATIF(oldTs[j], newTs[j]) < trigCoarsen);
250 if (coarsit ==
false)
254 for (
Integer j = 0, js = CELL_NB_H_CHILDREN(cell); j < js; ++j)
255 coarsit &= (ECART_RELATIF(newTs[j], newTs[(j + 1) % 4]) < trigCoarsen);
256 if (coarsit ==
false)
259 debug() <<
"\n\t\t\t\t\t\t[FaceAmrCoarsen] parent cell to COARSE #" << cell.
localId();
262 parents_to_coarsen_lid.
add((*iCell).localId());
266 ARCANE_ASSERT(((*iCell).isActive()), (
"Parent not active!"));
269 m_cell_temperature[iCell] = sumTs / 4.0;
272 for (
Integer j = 0, js = CELL_NB_H_CHILDREN(cell); j < js; ++j) {
273 children_to_coarsen_lid.
add(CELL_H_CHILD(cell, j).localId());
281 if ((!face.backCell().null()) && (!face.frontCell().null())) {
282 debug() <<
"\t\t\t[FaceAmrCoarsen] FOCUS face #" << face.localId() <<
", "
283 << face.backCell().localId() <<
"->"
284 << face.frontCell().localId();
286 const Cell& neighbour = (face.backCell().localId() == parent.
localId()) ? face.frontCell() : face.backCell();
287 debug() <<
"\t\t\t[FaceAmrCoarsen] neighbour #" << neighbour.
localId() <<
", level=" << neighbour.
level();
290 ARCANE_ASSERT((neighbour.
level() == 0), (
"Wrong neighbour level!"));
294 debug() <<
"\t\t\t[FaceAmrCoarsen] neighbour is ACTIVE";
295 debug() <<
"\t\t\t[FaceAmrCoarsen] hit: face_" << face.localId() <<
": " << neighbour.
localId() <<
"->" << parent.
localId();
307 found[0] = found[1] =
false;
309 for (
Integer j = 0, js = CELL_NB_H_CHILDREN(neighbour); j < js; ++j) {
312 auto faces = CELL_H_CHILD(neighbour, j).faces();
313 for (
Face face : faces) {
314 if (face.backCell().null())
316 if (face.frontCell().null())
319 Cell other = (face.frontCell().localId() == CELL_H_CHILD(neighbour, j).localId()) ? face.backCell() : face.frontCell();
323 if (other.
level() == 0)
327 if (CELL_H_PARENT(other).localId() != parent.
localId())
330 debug() <<
"\t\t\t\t[FaceAmrCoarsen] hit: face_" << face.
localId() <<
": " << CELL_H_CHILD(neighbour, j).localId() <<
"->" << parent.
localId();
331 faces_to_attach.
add(face.localId());
333 found[iFound++] =
true;
342 else if (face.backCell().null()) {
343 debug() <<
"\t\t\t[FaceAmrCoarsen] skip face #" << face.localId() <<
", ?->" << face.frontCell().localId() <<
" ";
346 debug() <<
"\t\t\t[FaceAmrCoarsen] skip face #" << face.localId() <<
", " << face.backCell().localId() <<
"->?"
353 if (parents_to_coarsen_lid.
size() == 0)
360 for (
Integer j = 0, js = children_to_coarsen_lid.
size(); j < js; ++j) {
363 dynMesh->trueCellFamily().
removeCell(cells_view[children_to_coarsen_lid[j]]);
373 for (
Integer j = 0, js = faces_to_attach.
size(); j < js; ++j) {
374 Face face = faces_view[faces_to_attach[j]];
376 debug() <<
"\t\t[FaceAmrCoarsen] NOW patch face_" << faces_to_attach[j] <<
": " << face.
backCell().
localId() <<
"->" << lids_to_be_attached[j];
378 dynMesh->trueFaceFamily().
addFrontCellToFace(face, cells_view[lids_to_be_attached[j]]);
381 debug() <<
"\t\t[FaceAmrCoarsen] NOW patch face_" << faces_to_attach[j] <<
": " << face.
frontCell().
localId() <<
"->" << lids_to_be_attached[j];
383 dynMesh->trueFaceFamily().
addBackCellToFace(face, cells_view[lids_to_be_attached[j]]);
385 faceReorienter.checkAndChangeOrientation(face);
390 mesh()->modifier()->endUpdate();
392 debug() <<
"\t\t[FaceAmrCoarsen] nbCell=" << MESH_ALL_ACTIVE_CELLS(
mesh()).size();
416 debug() <<
"[AlephTestModule::FaceAmrCoarsen] done";
Integer size() const
Number of elements in the vector.
Matrix of a linear system.
void setValue(const VariableRef &, const Item &, const VariableRef &, const Item &, const Real)
setValue from arguments in IVariables, Items, and Real
void fill(ConstReferenceType value)
Fills the array with the value value.
void add(ConstReferenceType val)
Adds element val to the end of the array.
View of cell information.
FaceConnectedListViewType faces() const
List of faces of the cell.
Face face(Int32 i) const
i-th face of the cell
View of face information.
This function/class reorients faces.
Cell frontCell() const
Cell in front of the face (null cell if none).
Cell backCell() const
Cell behind the face (null cell if none).
Int32 flags() const
Flags of the entity.
@ II_Inactive
The entity is inactive //COARSEN_INACTIVE,.
@ II_Refine
The entity is marked for refinement.
@ II_HasBackCell
The entity has a back cell.
@ II_CoarsenInactive
The entity is inactive and has children tagged for coarsening.
impl::MutableItemBase mutableItemBase() const
Mutable internal part of the entity.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
impl::ItemBase itemBase() const
Internal part of the entity.
void addFlags(Int32 added_flags)
Adds the flags added_flags to those of the entity.
Structure containing the information to create a service.
void removeCell(Cell cell)
Implementation of a mesh.
void addFrontCellToFace(Face face, Cell new_cell)
Adds a front cell to the face.
void addBackCellToFace(Face face, Cell new_cell)
Adds a back cell to the face.
ItemGroupT< Face > FaceGroup
Group of faces.
Int32 Integer
Type representing an integer.
Array< Integer > IntegerArray
Dynamic one-dimensional array of integers.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
Array< Real > RealArray
Dynamic one-dimensional array of reals.