61 if (isAthermal())
return 0.0;
66 system().domain().lattice());
67 if (nvParamId != paramId)
return 0.0;
77 int nMonomer = system().mixture().nMonomer();
78 int nx = system().domain().mesh().size();
79 RField<D> const & maskRGrid = system().mask().rgrid();
81 maskDeriv.
allocate(system().domain().mesh().dimensions());
82 hDeriv.
allocate(system().domain().mesh().dimensions());
92 for (
int ind = 0; ind < 3; ind++) {
94 dim[ind] = system().domain().mesh().dimensions()[ind];
101 for (x = 0; x < dim[0]; x++) {
103 for (y = 0; y < dim[1]; y++) {
105 for (z = 0; z < dim[2]; z++) {
107 maskVal = maskRGrid[counter];
111 d = (double)coords[normalVecId()] /
112 (double)dim[normalVecId()];
114 maskDeriv[counter] = maskVal * (maskVal - 1) * 8.0
115 * (std::abs(d - 0.5) - 0.5)
116 / interfaceThickness();
122 for (
int i = 0; i < nMonomer; i++) {
125 for (x = 0; x < dim[0]; x++) {
127 for (y = 0; y < dim[1]; y++) {
129 for (z = 0; z < dim[2]; z++) {
131 if (coords[normalVecId()] < (dim[normalVecId()] / 2)) {
132 hDeriv[counter] = -1.0 * maskDeriv[counter] * chiBottom(i);
134 hDeriv[counter] = -1.0 * maskDeriv[counter] * chiTop(i);
142 RField<D> const & c = system().c().rgrid(i);
143 for (
int i = 0; i < nx; i++) {
144 term += c[i] * hDeriv[i];
147 term /= (system().mask().phiTot() * nx);
157 UTIL_CHECK(system().domain().unitCell().isInitialized());
160 system().h().setFieldIo(system().domain().fieldIo());
164 if (!system().h().isAllocatedRGrid()) {
165 system().h().allocateRGrid(system().domain().mesh().dimensions());
167 if (system().iterator().isSymmetric()) {
168 UTIL_CHECK(system().domain().basis().isInitialized());
169 if (!system().h().isAllocatedBasis()) {
170 system().h().allocateBasis(system().domain().basis().nBasis());
185 if ((isAthermal()) && (!isGenerated()))
return;
189 UTIL_CHECK(system().mask().isAllocatedRGrid());
190 if (system().iterator().isSymmetric()) {
192 UTIL_CHECK(system().mask().isAllocatedBasis());
198 chiBottomCurrent_ = chiBottom();
199 chiTopCurrent_ = chiTop();
200 normalVecCurrent_ = systemLatticeVector(normalVecId());
202 int nm = systemNMonomer();
207 for (
int ind = 0; ind < 3; ind++) {
209 dim[ind] = system().domain().mesh().dimension(ind);
216 RField<D> const & maskPtr = system().mask().rgrid();
221 for (
int i = 0; i < nm; i++) {
222 hRGrid[i].
allocate(system().domain().mesh().dimensions());
230 for (i = 0; i < nm; i++) {
231 for (x = 0; x < dim[0]; x++) {
233 for (y = 0; y < dim[1]; y++) {
235 for (z = 0; z < dim[2]; z++) {
240 rhoW = maskPtr[counter];
241 if (coords[normalVecId()] < (dim[normalVecId()]/2)) {
242 hRGrid[i][counter++] = (1.0-rhoW) * chiBottom(i);
244 hRGrid[i][counter++] = (1.0-rhoW) * chiTop(i);
253 system().h().setRGrid(hRGrid, system().iterator().isSymmetric());