Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfPotential_cuda.h
1/*******************************************************************************
2 * This file is part of mdcore.
3 * Copyright (c) 2022-2024 T.J. Sego
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
20#ifndef _MDCORE_SOURCE_TFPOTENTIAL_CUDA_H_
21#define _MDCORE_SOURCE_TFPOTENTIAL_CUDA_H_
22
23#include <tfPotential.h>
24#include <tfDPDPotential.h>
25
26#include "tfParticle_cuda.h"
27
28
29namespace TissueForge::cuda {
30
31
40
41
42 __host__ __device__
43 void cudaFree(TissueForge::Potential *p);
44
45
48 uint32_t flags;
49
50 // a, b, r0_plusone
51 float3 w;
52
54 float3 offset;
55
57 float4 alpha;
58
60 int n;
61
63 float *c;
64
65 __host__
66 PotentialData() : flags{POTENTIAL_NONE} {}
67
68 __host__
70
71 __host__
72 void finalize();
73 };
74
77 uint32_t flags;
78
79 // a, b
80 float2 w;
81
82 // DPD coefficients alpha, gamma, sigma
83 float3 dpd_cfs;
84
85 __host__
86 DPDPotentialData() : flags{POTENTIAL_NONE} {}
87
88 __host__
90 };
91
92 // A wrap of Potential
93 struct Potential {
94 // Number of underlying potentials
95 int nr_pots;
96
97 // Number of dpd potentials
98 int nr_dpds;
99
100 // Data of all underlying potentials, excluding dpd
101 PotentialData *data_pots;
102
103 // Data of all underlying dpd potentials
104 DPDPotentialData *data_dpds;
105
106 __host__ __device__
107 Potential() :
108 nr_pots{0},
109 nr_dpds{0}
110 {}
111
112 __host__
114
115 __host__
116 void finalize() {
117 if(this->nr_pots == 0 && this->nr_dpds)
118 return;
119
120 for(int i = 0; i < this->nr_pots; i++)
121 this->data_pots[i].finalize();
122
123 this->nr_pots = 0;
124 this->nr_dpds = 0;
125 }
126 };
127
128};
129
130#endif // _MDCORE_SOURCE_TFPOTENTIAL_CUDA_H_
Tissue Forge GPU acceleration on CUDA-supporting devices.
Definition tfAngleConfig.h:26
TissueForge::Potential toCUDADevice(const TissueForge::Potential &p)
Loads a potential onto a CUDA device.
Definition tfDPDPotential.h:36
A Potential object is a compiled interpolation of a given function. The Universe applies potentials t...
Definition tfPotential.h:213
Definition tfPotential_cuda.h:75
uint32_t flags
Definition tfPotential_cuda.h:77
Definition tfPotential_cuda.h:46
float4 alpha
Definition tfPotential_cuda.h:57
int n
Definition tfPotential_cuda.h:60
float3 offset
Definition tfPotential_cuda.h:54
uint32_t flags
Definition tfPotential_cuda.h:48
float * c
Definition tfPotential_cuda.h:63
Definition tfPotential_cuda.h:93