Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
UniformOnSphere.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* UniformOnSphere.h (C) 2000-2014 */
9/* */
10/* Randomiser 'Uniform0nSphere'. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13#ifndef ARCANE_RANDOM_UNIFORMONSPHERE_H
14#define ARCANE_RANDOM_UNIFORMONSPHERE_H
15/*---------------------------------------------------------------------------*/
16/*---------------------------------------------------------------------------*/
17
18#include "arcane/utils/FatalErrorException.h"
19#include "arcane/utils/Real3.h"
20
21#include "arcane/random/NormalDistribution.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26ARCANE_BEGIN_NAMESPACE
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31RANDOM_BEGIN_NAMESPACE
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36/*
37 * Copyright Jens Maurer 2000-2001
38 * Permission to use, copy, modify, sell, and distribute this software
39 * is hereby granted without fee provided that the above copyright notice
40 * appears in all copies and that both that copyright notice and this
41 * permission notice appear in supporting documentation,
42 *
43 * Jens Maurer makes no representations about the suitability of this
44 * software for any purpose. It is provided "as is" without express or
45 * implied warranty.
46 *
47 * See http://www.boost.org for most recent version including documentation.
48 *
49 * $Id: UniformOnSphere.h 7934 2007-01-16 08:49:47Z grospelx $
50 *
51 * Revision history
52 * 2001-02-18 moved to individual header files
53 */
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57
58template<class UniformRandomNumberGenerator>
60{
61 public:
63 typedef Real3 result_type;
64
65 explicit UniformOnSphere(base_type & rng)
66 : _rng(rng) { }
67
68 typedef typename base_type::result_type base_result;
69 Real3 applyDim3()
70 {
71 Real results[3];
72 Real sqsum = 0;
73 for( Integer i=0; i<3; ++i ){
74 Real val = _rng();
75 val += 1.0e-16;
76 results[i] = val;
77 //cout << " VAL " << i << " =" << val << '\n';
78 sqsum += val * val;
79 }
80 //cout << " SQSUM " << sqsum << '\n';
81 Real inv_sqrt_sqsum = 1. / math::sqrt(sqsum);
82 //cout << " INV_SQSUM " << inv_sqrt_sqsum << '\n';
83 for( Integer i=0; i<3; ++i ){
85 }
86 return Real3(results[0],results[1],results[2]);
87 }
88 private:
89
91};
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96RANDOM_END_NAMESPACE
97ARCANE_END_NAMESPACE
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102#endif
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132